package com.supermap.desktop;

import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.io.*;
import java.lang.reflect.Constructor;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Random;
import java.util.concurrent.CopyOnWriteArrayList;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import com.supermap.data.Charset;
import com.supermap.data.CoordSysTransMethod;
import com.supermap.data.CoordSysTransParameter;
import com.supermap.data.CoordSysTranslator;
import com.supermap.data.Dataset;
import com.supermap.data.DatasetType;
import com.supermap.data.Datasets;
import com.supermap.data.Datasource;
import com.supermap.data.DatasourceConnectionInfo;
import com.supermap.data.EncodeType;
import com.supermap.data.EngineInfo;
import com.supermap.data.EngineType;
import com.supermap.data.ErrorInfo;
import com.supermap.data.GeoRegion;
import com.supermap.data.Geometry;
import com.supermap.data.Point2D;
import com.supermap.data.Point2Ds;
import com.supermap.data.Recordset;
import com.supermap.data.Rectangle2D;
import com.supermap.data.Toolkit;
import com.supermap.data.Workspace;
import com.supermap.data.WorkspaceConnectionInfo;
import com.supermap.data.WorkspaceType;
import com.supermap.data.DatasetVector;
import com.supermap.desktop.Interface.IBaseItem;
import com.supermap.desktop.Interface.ICtrlAction;
import com.supermap.desktop.Interface.IForm;
import com.supermap.desktop.Interface.IFormLayout;
import com.supermap.desktop.Interface.IFormMap;
import com.supermap.desktop.Interface.IFormScene;
import com.supermap.desktop.Interface.IFormTabular;
import com.supermap.desktop.enums.OpenWorkspaceResult;
import com.supermap.desktop.enums.WindowType;
import com.supermap.desktop.event.NewWindowEvent;
import com.supermap.desktop.event.NewWindowListener;
import com.supermap.desktop.event.SaveWorkspaceEvent;
import com.supermap.desktop.event.SaveWorkspaceListener;
import com.supermap.desktop.implement.SmMenu;
import com.supermap.desktop.implement.SmMenuItem;
import com.supermap.desktop.properties.CommonProperties;
import com.supermap.desktop.properties.CoreProperties;
import com.supermap.desktop.ui.XMLCommand;
import com.supermap.desktop.utilties.PathUtilties;
import com.supermap.desktop.utilties.XmlUtilties;
import com.supermap.mapping.Layer;
import com.supermap.mapping.LayerGroup;
import com.supermap.mapping.LayerSettingVector;
import com.supermap.mapping.Layers;
import com.supermap.mapping.Map;
import com.supermap.realspace.Camera;
import com.supermap.realspace.Layer3DDataset;
import com.supermap.realspace.Layer3Ds;
import com.supermap.realspace.Scene;
import com.supermap.realspace.TerrainLayers;

public class CommonToolkit {

	public CommonToolkit() {
		ApplicationInfoWrap.validateDesktopType();
	}

	public static class ApplicationWrap {

		public static Datasource getActiveDatasource(boolean canWriteOnly) {
			Datasource datasource = null;
			try {
				for (int index = 0; index < Application.getActiveApplication().getWorkspace().getDatasources().getCount(); index++) {
					Datasource item = Application.getActiveApplication().getWorkspace().getDatasources().get(index);
					if (!canWriteOnly || !item.isReadOnly()) {
						datasource = item;
						break;
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return datasource;
		}

	}

	public static class AltitudeModeWrap {

		// #region Variable
		// static Dictionary<AltitudeMode, String> sceneAltitudeModes = null;
		// #endregion
		//
		// #region Property
		//
		// #endregion
		//
		// #region Construct
		// static AltitudeModeWrap()
		// {
		// Initialize();
		// }
		//
		// private static void Initialize()
		// {
		// if (sceneAltitudeModes == null)
		// {
		// sceneAltitudeModes = new Dictionary<AltitudeMode, String>();
		// sceneAltitudeModes.Add(AltitudeMode.Absolute,
		// CoreResources.String_AltitudeMode_Absolute);
		// sceneAltitudeModes.Add(AltitudeMode.ClampToGround,
		// CoreResources.String_AltitudeMode_ClampToGround);
		// sceneAltitudeModes.Add(AltitudeMode.RelativeToGround,
		// CoreResources.String_AltitudeMode_RelativeToGround);
		// sceneAltitudeModes.Add(AltitudeMode.ModifyTerrain,
		// CoreResources.String_AltitudeMode_ModifyTerrain);
		// sceneAltitudeModes.Add(AltitudeMode.ClampToObject,
		// CoreResources.String_AltitudeMode_ClampToObject);
		// // 地下模式
		// sceneAltitudeModes.Add(AltitudeMode.AbsoluteUnderGround,
		// CoreResources.String_AltitudeMode_Absolute);
		// sceneAltitudeModes.Add(AltitudeMode.RelativeUnderGround,
		// CoreResources.String_AltitudeMode_RelativeToGround);
		// }
		// }
		// #endregion
		//
		// #region Function_Public
		// private static Dictionary<AltitudeMode, String> SceneAltitudeModes
		// {
		// get
		// {
		// return sceneAltitudeModes;
		// }
		// }
		//
		// /// <summary>
		// /// 根据高度模式类型资源字符串获取对应的高度模式类型
		// /// </summary>
		// public static AltitudeMode getAltitudeMode(String name)
		// {
		// AltitudeMode result = AltitudeMode.ClampToGround;
		//
		// try
		// {
		// foreach (KeyValuePair<AltitudeMode, String> kvp in
		// SceneAltitudeModes)
		// {
		// if (kvp.Value.Equals(name))
		// {
		// result = kvp.Key;
		// break;
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return result;
		// }
		//
		// /// <summary>
		// /// 根据高度模式类型获取对应的资源字符串
		// /// </summary>
		// public static String getAltitudeModeName(AltitudeMode altitudeMode)
		// {
		// String strName = "Unknown";
		// try
		// {
		// strName = SceneAltitudeModes[altitudeMode];
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return strName;
		// }
		// #endregion
		//
		// #region Function_Event
		//
		// #endregion
		//
		// #region Function_Private
		//
		// #endregion
		//
		// #region Event
		//
		// #endregion
		//
		// #region InterfaceMembers
		//
		// #endregion
		//
		// #region NestedTypes
		//
		// #endregion
	}

	public static class ApplicationInfoWrap {

		// #region Variable
		// private static LicenseType DesktopType = LicenseType.Desktop_None;
		// private static LicenseMode g_LicenseMode;
		// private static DateTime g_ExpiredDate;
		// private static int LicenseTipMaxDays = 10;
		//
		// private static boolean isMainFormFirstLoad;
		// #endregion
		//
		// #region Property
		// /// <summary>
		// /// 当前Desktop应用的许可类型
		// /// </summary>
		// public static LicenseType DesktopType
		// {
		// get
		// {
		// return DesktopType;
		// }
		// }
		//
		// /// <summary>
		// /// 当前Desktop应用的许可方式
		// /// </summary>
		// public static LicenseMode LicenseMode
		// {
		// get
		// {
		// return g_LicenseMode;
		// }
		// }
		//
		// /// <summary>
		// /// 许可过期日期
		// /// </summary>
		// public static DateTime ExpiredDate
		// {
		// get
		// {
		// return g_ExpiredDate;
		// }
		// }
		//
		// /// <summary>
		// /// 许可提示显示最大天数
		// /// </summary>
		// public static int LicenseTipMaxDays
		// {
		// get
		// {
		// return LicenseTipMaxDays;
		// }
		// }
		//
		// /// <summary>
		// /// 指示桌面的主窗体是否第一次加载
		// /// </summary>
		// public static boolean IsMainFormFirstLoad
		// {
		// get
		// {
		// return isMainFormFirstLoad;
		// }
		// set
		// {
		// isMainFormFirstLoad = value;
		// }
		// }
		// #endregion
		//
		// #region Construct
		//
		// #endregion
		//

		/**
		 * 验证当前Desktop应用的许可信息
		 */
		public static void validateDesktopType() {
			try {
				// boolean isConnected = false;
				// SuperMap.Data.License license = new SuperMap.Data.License();
				// LicenseMode licenseMode = LicenseMode.NoLicense;
				// DateTime dateTime = new DateTime();
				// if (license.Connect(ProductType.iDesktopAdvanced) == 0)
				// {
				// DesktopType = LicenseType.Desktop_iDesktopAdvance;
				// isConnected = true;
				// }
				// else if (license.Connect(ProductType.iDesktopProfessional) ==
				// 0)
				// {
				// DesktopType = LicenseType.Desktop_iDesktopProfessional;
				// isConnected = true;
				// }
				// else if (license.Connect(ProductType.iDesktopStandard) == 0)
				// {
				// DesktopType = LicenseType.Desktop_iDesktopStandard;
				// isConnected = true;
				// }
				//
				// if (isConnected)
				// {
				// LicenseFeatureInfo info = license.getFeatureInfo();
				// if (info.IsTrial)
				// {
				// licenseMode = LicenseMode.TrialVersion;
				// }
				// else
				// {
				// licenseMode = LicenseMode.FormalVersion;
				// }
				// dateTime = (DateTime)info.ExpiredTime;
				//
				// ProductType[] types = Toolkit.getTrialLicenses();
				// boolean isTrialLicensesAvailable = false;
				// license.Disconnect();
				// //如果用户同时正在用正式许可（同时不带一些子功能的许可），和试用许可，那么这时把试用许可允许用的功能也加上。
				// foreach (ProductType item in types)
				// {
				// if (license.Connect(item) == 0)
				// {
				// isTrialLicensesAvailable = true;
				// break;
				// }
				// }
				// if (isTrialLicensesAvailable)
				// {
				// DesktopType |= LicenseType.Desktop_Topology;
				// DesktopType |= LicenseType.Desktop_TrafficNetwork;
				// DesktopType |= LicenseType.Desktop_FacilityNetwork;
				// DesktopType |= LicenseType.Desktop_Spatial;
				// DesktopType |= LicenseType.Desktop_Chart;
				// DesktopType |= LicenseType.Desktop_GeoProcesser;
				// DesktopType |= LicenseType.Desktop_RealspaceSpatialAnalyst;
				// DesktopType |= LicenseType.Desktop_RealspaceEffect;
				// DesktopType |= LicenseType.Desktop_RealspaceNetworkAnalyst;
				// }
				// else
				// {
				// if (license.Connect(ProductType.iDesktopTopology) == 0)
				// {
				// DesktopType |= LicenseType.Desktop_Topology;
				// }
				// if (license.Connect(ProductType.iDesktopTrafficNetwork) == 0)
				// {
				// DesktopType |= LicenseType.Desktop_TrafficNetwork;
				// }
				// if (license.Connect(ProductType.iDesktopFacilityNetwork) ==
				// 0)
				// {
				// DesktopType |= LicenseType.Desktop_FacilityNetwork;
				// }
				// if (license.Connect(ProductType.iDesktopSpatial) == 0)
				// {
				// DesktopType |= LicenseType.Desktop_Spatial;
				// }
				// if (license.Connect(ProductType.iDesktopChart) == 0)
				// {
				// DesktopType |= LicenseType.Desktop_Chart;
				// }
				// if (license.Connect(ProductType.iDesktopGeoProcesser) == 0)
				// {
				// DesktopType |= LicenseType.Desktop_GeoProcesser;
				// }
				// if
				// (license.Connect(ProductType.iDesktopRealspaceSpatialAnalyst)
				// == 0)
				// {
				// DesktopType |= LicenseType.Desktop_RealspaceSpatialAnalyst;
				// }
				// if (license.Connect(ProductType.iDesktopRealspaceEffect) ==
				// 0)
				// {
				// DesktopType |= LicenseType.Desktop_RealspaceEffect;
				// }
				// if (license.Connect(516) == 0)
				// {
				// DesktopType |= LicenseType.Desktop_RealspaceNetworkAnalyst;
				// }
				// }
				// }
				// else
				// {
				// ProductType[] types = Toolkit.getTrialLicenses();
				// foreach (ProductType item in types)
				// {
				// if (license.Connect(item) == 0)
				// {
				// license.Disconnect();//对于安装完桌面后首次访问组件返回的过期时间是有误，为确保正确，必须得重新Connect一下。
				// license.Connect(item);
				// isConnected = true;
				// DesktopType = LicenseType.Desktop_iDesktopProfessional;
				// licenseMode = LicenseMode.TrialVersion;
				// LicenseFeatureInfo info = license.getFeatureInfo();
				// dateTime = info.ExpiredTime;
				//
				// DesktopType |= LicenseType.Desktop_Topology;
				// DesktopType |= LicenseType.Desktop_TrafficNetwork;
				// DesktopType |= LicenseType.Desktop_FacilityNetwork;
				// DesktopType |= LicenseType.Desktop_Spatial;
				// DesktopType |= LicenseType.Desktop_Chart;
				// DesktopType |= LicenseType.Desktop_GeoProcesser;
				// DesktopType |= LicenseType.Desktop_RealspaceSpatialAnalyst;
				// DesktopType |= LicenseType.Desktop_RealspaceEffect;
				// DesktopType |= LicenseType.Desktop_RealspaceNetworkAnalyst;
				// break;
				// }
				// }
				// }
				// if (isConnected)
				// {
				// g_LicenseMode = licenseMode;
				// g_ExpiredDate = dateTime;
				// }
				// else
				// {
				// g_LicenseMode = LicenseMode.NoLicense;
				// }
				// license.Disconnect();
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
		}
		//
		// /// <summary>
		// /// 重新验证全套的许可，包括正在使用的和未使用的，然后累加过期时间
		// /// </summary>
		// /// <returns></returns>
		// public static boolean ReFullCheckUpLicenses()
		// {
		// boolean result = false;
		// try
		// {
		// String licenseInfo = String.Empty;
		// AdminStatus status = AdminAPIWrap.AdminConnect();
		// if (status == AdminStatus.OK)
		// {
		// status = AdminAPIWrap.Adminget(AdminAPIWrap.Scope,
		// AdminAPIWrap.getAllFeature, ref licenseInfo);
		// if (status == AdminStatus.OK)
		// {
		// result = true;
		// }
		// }
		//
		// if (result)
		// {
		// XmlDocument doc = new XmlDocument();
		// doc.LoadXml(licenseInfo);
		// XmlNode root = doc.SelectSingleNode("admin_response");
		// XmlNode lmNode = null;
		//
		// List<LicenseFeature> featureList = new List<LicenseFeature>();
		//
		// for (int i = 0; i < root.ChildNodes.Count; i++)
		// {
		// lmNode = root.ChildNodes.get(i);
		// if (lmNode.Name == "feature")
		// {
		// List<LicenseFeature> productList = new List<LicenseFeature>();
		// LicenseFeature feature = LicenseFeature.FormXml(lmNode.OuterXml);
		// if (feature != null)
		// {
		// featureList.Add(feature);
		// }
		// }
		// }
		//
		// TimeSpan remainTime = TimeSpan.Zero;
		// foreach (LicenseFeature item in featureList)
		// {
		// // 如果已经开始使用了
		// if (!item.StartTime.Equals(DateTime.MinValue))
		// {
		// remainTime += item.EndTime - DateTime.Now;
		// }
		// else
		// {
		// remainTime += item.LastDesTimeSpan;
		// }
		// }
		//
		// g_ExpiredDate = DateTime.Now + remainTime;
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return result;
		// }
		//
		// //判断当前版本桌面是否支持加载外部插件，暂定所有扩展系列的产品都支持加载外部插件
		// public static boolean AllowExternalAssemblyRun()
		// {
		// return IsDesktop();
		// }
		//
		// //判断当前应用许可是否属于桌面Desktop系列，iMapEditor系列的dll不应能在Desktop系列上运行。
		// public static boolean IsDesktop()
		// {
		// return (((CommonToolkit.ApplicationInfoWrap.DesktopType &
		// LicenseType.Desktop_iDesktopProfessional) ==
		// LicenseType.Desktop_iDesktopProfessional)
		// || ((CommonToolkit.ApplicationInfoWrap.DesktopType &
		// LicenseType.Desktop_iDesktopStandard) ==
		// LicenseType.Desktop_iDesktopStandard)
		// || ((CommonToolkit.ApplicationInfoWrap.DesktopType &
		// LicenseType.Desktop_iDesktopAdvance) ==
		// LicenseType.Desktop_iDesktopAdvance));
		// //|| ((CommonToolkit.ApplicationInfoWrap.DesktopType &
		// LicenseType.Desktop_iMapEditor) == LicenseType.Desktop_iMapEditor)
		// }
		//
		// public static boolean IsLicenseAvailable()
		// {
		// return (CommonToolkit.ApplicationInfoWrap.IsDesktop()
		// && (CommonToolkit.ApplicationInfoWrap.ExpiredDate -
		// DateTime.Today).TotalDays > 0);
		// }
		//
		// public static String getLicenseRemainTimeTip(LicenseMode mode,
		// TimeSpan remainTime)
		// {
		// String result = CoreResources.String_Label_InvalidationSuggestion;
		// try
		// {
		// if (mode == LicenseMode.TrialVersion)
		// {
		// if (remainTime != null)
		// {
		// Double timeCount = remainTime.TotalDays;
		// if (timeCount > 90 || timeCount < -365000)//days <
		// -365000是针对安装完桌面第一次打开时，曾经访问到组件的过期时间是0001/01/01，这时其实是刚开始试用，应该提示剩余90天。
		// {
		// timeCount = 90;
		// }
		//
		// if (timeCount >= 1)
		// {
		// result = String.format(CoreResources.String_Label_SuggestionDay,
		// (int)timeCount);
		// }
		// else if (timeCount > 0)
		// {
		// timeCount = remainTime.TotalHours;
		// if (timeCount >= 1)
		// {
		// result = String.format(CoreResources.String_Label_SuggestionHour,
		// (int)timeCount);
		// }
		// else
		// {
		// result = String.format(CoreResources.String_Label_SuggestionHour,
		// Math.Round(timeCount, 1));
		// }
		// }
		// else
		// {
		// result = CoreResources.String_Label_InvalidationSuggestion;
		// }
		// }
		// }
		// else if (mode == LicenseMode.NoLicense)
		// {
		// result = CoreResources.String_Label_NoLicenseSuggestion;
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return result;
		// }
	}

	public static class AssemblyWrap {

		// #region Variable
		// const String g_strDesktopPublicKeyToken = "7cd7dcc384397b6e";
		// const String g_strTestPublicKeyToken = "23d8e753f5ab9fa4";
		// #endregion
		//
		// #region Property
		//
		// #endregion
		//
		// #region Construct
		//
		// #endregion
		//
		// #region Function_Public
		// /// <summary>
		// /// 根据程序集的显示名称判断是否SuperMap程序集
		// /// </summary>
		// public static boolean IsSuperMapAssembly(String strFullName)
		// {
		// boolean bIsSuperMapAssembly = false;
		// try
		// {
		// String[] s = strFullName.Split(',');
		// for (int i = 0; i < s.Length; i++)
		// {
		// String str = s.get(i).TrimStart();
		// if (str.StartsWith("PublicKeyToken"))
		// {
		// String strPublicKeyToken = str.Replace("PublicKeyToken=", "");
		// if (strPublicKeyToken.Equals(g_strDesktopPublicKeyToken) ||
		// strPublicKeyToken.Equals(g_strTestPublicKeyToken))
		// {
		// bIsSuperMapAssembly = true;
		// }
		// break;
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return bIsSuperMapAssembly;
		// }
		//
		// /// <summary>
		// /// 根据插件信息判断插件对应的程序集是否SuperMap程序集
		// /// </summary>
		// public static boolean IsSuperMapAssembly(PluginInfo info)
		// {
		// boolean bIsSuperMapAssembly = false;
		// try
		// {
		// String path =
		// CommonToolkit.PathWrap.getFullPathName(info.AssemblyName);
		// if (System.IO.File.Exists(path))
		// {
		// System.Reflection.Assembly assembly =
		// System.Reflection.Assembly.LoadFrom(path);
		// bIsSuperMapAssembly = IsSuperMapAssembly(assembly.FullName);
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return bIsSuperMapAssembly;
		// }
		// #endregion
	}

	public static class CharsetWrap {

		// #region Variable
		// private static Dictionary<Charset, String> dictionaryCharset;
		// #endregion
		//
		// #region Property
		// /// <summary>
		// /// 字符集类型与引用资源字典
		// /// </summary>
		// public static Dictionary<Charset, String> DictionaryCharset
		// {
		// get
		// {
		// return dictionaryCharset;
		// }
		// }
		// #endregion
		//
		// #region Construct
		// static CharsetWrap()
		// {
		// Initialize();
		// }
		// #endregion
		//
		// #region Function_Public
		// /// <summary>
		// /// 初始化字符集封装类
		// /// </summary>
		// private static void Initialize()
		// {
		// try
		// {
		// dictionaryCharset = new Dictionary<Charset, string>();
		// dictionaryCharset.Add(Charset.ANSI,
		// CoreResources.String_Charset_ANSI);
		// dictionaryCharset.Add(Charset.Arabic,
		// CoreResources.String_Charset_Arabic);
		// dictionaryCharset.Add(Charset.Baltic,
		// CoreResources.String_Charset_Baltic);
		// dictionaryCharset.Add(Charset.ChineseBIG5,
		// CoreResources.String_Charset_ChineseBIG5);
		// dictionaryCharset.Add(Charset.Cyrillic,
		// CoreResources.String_Charset_Cyrillic);
		// dictionaryCharset.Add(Charset.Default,
		// CoreResources.String_Charset_Default);
		// dictionaryCharset.Add(Charset.EastEurope,
		// CoreResources.String_Charset_EastEurope);
		// dictionaryCharset.Add(Charset.GB18030,
		// CoreResources.String_Charset_GB18030);
		// dictionaryCharset.Add(Charset.Greek,
		// CoreResources.String_Charset_Greek);
		// dictionaryCharset.Add(Charset.Hangeul,
		// CoreResources.String_Charset_Hangeul);
		// dictionaryCharset.Add(Charset.Hebrew,
		// CoreResources.String_Charset_Hebrew);
		// dictionaryCharset.Add(Charset.ISO2022JP2,
		// CoreResources.String_Charset_ISO2022JP2);
		// dictionaryCharset.Add(Charset.Johab,
		// CoreResources.String_Charset_Johab);
		// dictionaryCharset.Add(Charset.Korean,
		// CoreResources.String_Charset_Korean);
		// dictionaryCharset.Add(Charset.MAC,
		// CoreResources.String_Charset_MAC);
		// dictionaryCharset.Add(Charset.OEM,
		// CoreResources.String_Charset_OEM);
		// dictionaryCharset.Add(Charset.Russian,
		// CoreResources.String_Charset_Russian);
		// dictionaryCharset.Add(Charset.ShiftJIS,
		// CoreResources.String_Charset_ShiftJIS);
		// dictionaryCharset.Add(Charset.Symbol,
		// CoreResources.String_Charset_Symbol);
		// dictionaryCharset.Add(Charset.Thai,
		// CoreResources.String_Charset_Thai);
		// dictionaryCharset.Add(Charset.Turkish,
		// CoreResources.String_Charset_Turkish);
		// dictionaryCharset.Add(Charset.Unicode,
		// CoreResources.String_Charset_Unicode);
		// //dictionaryCharset.Add(Charset.UTF32,
		// CoreResources.String_Charset_UTF32);
		// dictionaryCharset.Add(Charset.UTF7,
		// CoreResources.String_Charset_UTF7);
		// dictionaryCharset.Add(Charset.UTF8,
		// CoreResources.String_Charset_UTF8);
		// dictionaryCharset.Add(Charset.Vietnamese,
		// CoreResources.String_Charset_Vietnamese);
		// dictionaryCharset.Add(Charset.Windows1252,
		// CoreResources.String_Charset_Windows1252);
		// dictionaryCharset.Add(Charset.xIA5,
		// CoreResources.String_Charset_XIA5);
		// dictionaryCharset.Add(Charset.xIA5German,
		// CoreResources.String_Charset_XIA5German);
		// dictionaryCharset.Add(Charset.xIA5Norwegian,
		// CoreResources.String_Charset_XIA5Norwegian);
		// dictionaryCharset.Add(Charset.xIA5Swedish,
		// CoreResources.String_Charset_XIA5Swedish);
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// }
		//

		/**
		 * 根据字符集类型获取对应的资源字符串
		 * 
		 * @param charset
		 * @return
		 */
		public static String getCharsetName(Charset charset) {
			String charsetInfo = "";
			try {
				// charsetInfo = dictionaryCharset[charset];
				charsetInfo = charset.toString();
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return charsetInfo;
		}

		/**
		 * 根据字符集资源字符串获取对应的字符集类型
		 * 
		 * @param charsetString 字符集名称
		 * @return 字符集类型
		 */
		public static Charset getCharset(String charsetString) {
			Charset charset = Charset.UTF8;
			try {
				// foreach (KeyValuePair<Charset, String> kvp in
				// dictionaryCharset) {
				// if (kvp.Value.Equals(charsetString))
				// {
				// charset = kvp.Key;
				// break;
				// }
				// }
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return charset;
		}
	}

	public static class ColorWrap {

		// #region Variable
		//
		// #endregion
		//
		// #region Property
		//
		// #endregion
		//
		// #region Construct
		//
		// #endregion
		//
		// #region Function_Public
		// /// <summary>
		// /// 将RGB中的A分量转化为百分比的透明度
		// /// </summary>
		// public static int getOpaqueRateFromAlpha(int alpha)
		// {
		// return (int)(Math.Round(alpha / 255.0 * 100.0,
		// MidpointRounding.AwayFromZero));
		// }
		//
		// /// <summary>
		// /// 将百分比的透明度转化为RGB中的A分量
		// /// </summary>
		// public static int getAlphaFromOpaqueRate(int opaqueRate)
		// {
		// return (int)(Math.Round(opaqueRate / 100.0 * 255.0,
		// MidpointRounding.AwayFromZero));
		// }
		// #endregion
		//
		// #region Function_Event
		//
		// #endregion
		//
		// #region Function_Private
		//
		// #endregion
		//
		// #region Event
		//
		// #endregion
		//
		// #region InterfaceMembers
		//
		// #endregion
		//
		// #region NestedTypes
		//
		// #endregion
	}

	public static class CtrlActionWrap {

		// #region Variable
		//
		// #endregion
		//
		// #region Property
		// private static Keys[] keys;
		// public static Keys[] AllKeys
		// {
		// get
		// {
		// if (keys == null)
		// {
		// List<Keys> keys = new List<Keys>();
		// foreach (int i in Enum.getValues(typeof(Keys)))
		// {
		// keys.Add((Keys)i);
		// }
		// keys = keys.ToArray();
		// }
		// return keys;
		// }
		// }
		/**
		 * 根据具体参数构造CtrlAction
		 * 
		 * @param xmlCommand
		 * @param caller
		 * @param formClass
		 * @return
		 */
		public static ICtrlAction getCtrlAction(XMLCommand xmlCommand, IBaseItem caller, IForm formClass) {
			ICtrlAction ctrlAction = null;
			try {
				// 这里先临时处理一下文件名
				String[] names = xmlCommand.getPluginInfo().getBundleName().split("/");
				String fileName = names[names.length - 1];
				fileName = fileName.replaceAll(".dll", "");
				fileName = fileName.replaceAll(".jar", "");

				Class<?> ctrlActionClass = Application.getActiveApplication().getPluginManager()
						.getBundleClass(fileName.toLowerCase(), xmlCommand.getCtrlActionClass());

				if (ctrlActionClass != null) {
					Class[] paramTypes = { IBaseItem.class, IForm.class };
					Object[] params = { caller, formClass }; // 方法传入的参数
					Constructor<?> constructor = ctrlActionClass.getConstructor(paramTypes);
					ctrlAction = (ICtrlAction) constructor.newInstance(params);
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
				Application.getActiveApplication().getOutput().output(xmlCommand.getPluginInfo().getBundleName() + "&" + xmlCommand.getCtrlActionClass());
			}
			return ctrlAction;
		}
		//
		// #region Function_Public
		// /// <summary>
		// /// 读取XML节点构造CtrlAction
		// /// </summary>
		// public static ICtrlAction getCtrlAction(XmlNode itemNode, IBaseItem
		// caller, IForm formClass)
		// {
		// ICtrlAction ctrlAction = null;
		//
		// try
		// {
		// String className = _XMLTag.g_Empty;
		// String assemblyName = _XMLTag.g_Empty;
		// String codeType = _XMLTag.g_Empty;
		// try
		// {
		// className = itemNode.Attributes[_XMLTag.g_OnAction].Value;
		// }
		// catch { }
		// try
		// {
		// assemblyName =
		// itemNode.Attributes[_XMLTag.g_AttributionAssemblyName].Value;
		// }
		// catch { }
		// try
		// {
		// codeType = itemNode.Attributes[_XMLTag.g_AttributionCodeType].Value;
		// }
		// catch { }
		// String code = itemNode.InnerText;
		// if (className != _XMLTag.g_Empty)
		// {
		// ctrlAction = getCtrlAction(className, assemblyName, code, caller,
		// formClass, codeType);
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		//
		// return ctrlAction;
		// }
		//
		// /// <summary>
		// /// 根据具体参数构造CtrlAction
		// /// </summary>
		// public static ICtrlAction getCtrlAction(String className, String
		// assemblyName, String code, IBaseItem caller, IForm formClass, String
		// codeTypeString)
		// {
		// ICtrlAction ctrlAction = null;
		// try
		// {
		// if (className != null && className.Equals(_XMLTag.g_ScriptCodeFlag))
		// {
		//
		// //根据className属性确定是否为动态脚本
		// //String code = itemNode.InnerText;
		// CodeType codeType = CodeType.CSharp;
		// if (codeTypeString.toLowerCase().Equals(_XMLTag.g_ValueCodeType_VB))
		// {
		// codeType = CodeType.VB;
		// }
		// ctrlAction =
		// Application.getActiveApplication().Script.CompileCtrlActionCodeSnippet(codeType,
		// code);
		// }
		// else if (className != null &&
		// System.IO.File.Exists(CommonToolkit.PathWrap.getFullPathName(className)))
		// {
		//
		// String extension = System.IO.Path.getExtension(className);
		// CodeType codeType = CodeType.CSharp;
		// if (extension.toLowerCase().Equals(CoreResources.String_VBExtension))
		// {
		// codeType = CodeType.VB;
		// }
		// ctrlAction =
		// Application.getActiveApplication().Script.CompileCtrlActionClass(codeType,
		// new String[] { CommonToolkit.PathWrap.getFullPathName(className) });
		// }
		// else
		// {
		// //根据类名在指定动态库里生成对象
		// Assembly assembly = null;
		//
		// //查找一下是否已经加载进来了
		// Assembly[] assemblys = AppDomain.CurrentDomain.getAssemblies();
		// //非.net程序集的动态链接库没有元数据清单，因此虽然可以从当前AppDomain中知道它，但是无法读取
		// //其中的字段、引用等信息，会抛异常，需要过滤
		// foreach (Assembly a in assemblys)
		// {
		// if (!a.IsDynamic)
		// {
		// assembly = null;
		// if (assemblyName.Length != 0 &&
		// a.FullName.toLowerCase().IndexOf(assemblyName.toLowerCase()) == 0 ||
		// a.Location.toLowerCase().Equals(assemblyName.toLowerCase()))
		// {
		// assembly = a;
		// break;
		// }
		// }
		// }
		//
		// //如果没有加载，加载一下
		// if (assembly == null && assemblyName != null && assemblyName.Length
		// != 0)
		// {
		// assemblyName = CommonToolkit.PathWrap.getFullPathName(assemblyName);
		// assembly = System.Reflection.Assembly.LoadFrom(assemblyName);
		// }
		//
		// String exceptionMessage = String.Empty;
		// try
		// {
		// Type type = assembly.getType(className);
		// if (type != null)
		// {
		// ConstructorInfo constructor = type.getConstructor(new Type[] {
		// typeof(IBaseItem), typeof(IForm) });
		// if (constructor != null)
		// {
		// ctrlAction = constructor.Invoke(new object[] { caller, formClass })
		// as ICtrlAction;
		// }
		// }
		// }
		// catch (Exception ex)
		// {
		// exceptionMessage = ex.StackTrace;
		// }
		//
		// try
		// {
		// if (ctrlAction == null)
		// {
		// exceptionMessage = String.Empty;
		// ctrlAction = assembly.CreateInstance(className) as ICtrlAction;
		// }
		// }
		// catch (Exception ex)
		// {
		// exceptionMessage = ex.StackTrace;
		// }
		//
		// if (exceptionMessage.Length != 0)
		// {
		// Application.getActiveApplication().Output.Output(exceptionMessage,
		// InfoType.Exception);
		// }
		//
		// if (ctrlAction == null && Application.getActiveApplication().Output
		// != null)
		// {
		// Application.getActiveApplication().Output.Output("_CtrlActionNotImplemented");
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return ctrlAction;
		// }
		//
		// public static System.Windows.Forms.Keys getKeysByName(String name)
		// {
		// Keys result = Keys.None;
		// if
		// (name.toLowerCase().Equals(CoreResources.String_ShortCut_Ctrl.toLowerCase()))
		// {
		// result = Keys.Control;
		// }
		// else
		// {
		// foreach (Keys key in AllKeys)
		// {
		// if (key.ToString().Equals(name))
		// {
		// result = key;
		// break;
		// }
		// }
		// }
		//
		// return result;
		// }
		// #endregion
		//
		// #region Function_Event
		//
		// #endregion
		//
		// #region Function_Private
		//
		// #endregion
		//
		// #region Event
		//
		// #endregion
		//
		// #region InterfaceMembers
		//
		// #endregion
		//
		// #region NestedTypes
		//
		// #endregion
	}

	public static class DatasetTypeWrap {

		private static HashMap<DatasetType, String> datasetTypes = null;

		/**
		 * 初始化数据集类型字典
		 */
		private static void initialize() {
			if (datasetTypes != null) {
				return;
			}

			datasetTypes = new HashMap<DatasetType, String>(22);

			datasetTypes.put(DatasetType.TABULAR, CommonProperties.getString("String_DatasetType_Tabular"));
			datasetTypes.put(DatasetType.POINT, CommonProperties.getString("String_DatasetType_Point"));
			datasetTypes.put(DatasetType.LINE, CommonProperties.getString("String_DatasetType_Line"));
			datasetTypes.put(DatasetType.NETWORK, CommonProperties.getString("String_DatasetType_Network"));
			datasetTypes.put(DatasetType.REGION, CommonProperties.getString("String_DatasetType_Region"));
			datasetTypes.put(DatasetType.TEXT, CommonProperties.getString("String_DatasetType_Text"));
			datasetTypes.put(DatasetType.PARAMETRICLINE, CommonProperties.getString("String_DatasetType_ParametricLine"));
			datasetTypes.put(DatasetType.PARAMETRICREGION, CommonProperties.getString("String_DatasetType_ParametricRegion"));
			// datasetTypes.put(DatasetType.R,
			// CommonProperties.getString("String_DatasetType_Router"));
			datasetTypes.put(DatasetType.IMAGE, CommonProperties.getString("String_DatasetType_Image"));
			datasetTypes.put(DatasetType.GRID, CommonProperties.getString("String_DatasetType_Grid"));
			datasetTypes.put(DatasetType.WMS, CommonProperties.getString("String_DatasetType_WMS"));
			datasetTypes.put(DatasetType.WCS, CommonProperties.getString("String_DatasetType_WCS"));
			datasetTypes.put(DatasetType.POINT3D, CommonProperties.getString("String_DatasetType_Point3D"));
			datasetTypes.put(DatasetType.LINE3D, CommonProperties.getString("String_DatasetType_Line3D"));
			datasetTypes.put(DatasetType.REGION3D, CommonProperties.getString("String_DatasetType_Region3D"));
			datasetTypes.put(DatasetType.CAD, CommonProperties.getString("String_DatasetType_CAD"));
			datasetTypes.put(DatasetType.LINKTABLE, CommonProperties.getString("String_DatasetType_LinkTable"));
			datasetTypes.put(DatasetType.TOPOLOGY, CommonProperties.getString("String_DatasetType_Topology"));
			datasetTypes.put(DatasetType.GRIDCOLLECTION, CommonProperties.getString("String_DatasetType_GridCollection"));
			datasetTypes.put(DatasetType.IMAGECOLLECTION, CommonProperties.getString("String_DatasetType_ImageCollection"));
			datasetTypes.put(DatasetType.MODEL, CommonProperties.getString("String_DatasetType_Model"));
			datasetTypes.put(DatasetType.IMAGECOLLECTION, CommonProperties.getString("String_DatasetType_ImageCollection"));
			datasetTypes.put(DatasetType.NETWORK, CommonProperties.getString("String_DatasetType_Network3D"));
		}

		/**
		 * 根据数据集类型资源字符串获取对应的数据集类型
		 * 
		 * @param typeName 数据集类型字符串
		 * @return 数据集类型
		 */
		public static DatasetType findType(String typeName) {
			DatasetType result = null;
			try {
				initialize();
				Iterator iter = datasetTypes.entrySet().iterator();
				while (iter.hasNext()) {
					java.util.Map.Entry entry = (java.util.Map.Entry) iter.next();
					String value = (String) entry.getValue();
					if (value.equals(typeName)) {
						result = (DatasetType) entry.getKey();
						break;
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return result;
		}

		/**
		 * 根据数据集类型获取对应的资源字符串
		 * 
		 * @param type 数据集类型
		 * @return 数据集类型字符串
		 */
		public static String findName(DatasetType type) {
			String result = "";
			try {
				initialize();
				if (datasetTypes.get(type) == null) {
					result = CommonProperties.getString("String_DatasetType_Unknown");
				} else {
					result = datasetTypes.get(type);
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return result;
		}

		/**
		 * 验证数据集类型是否存在于枚举中
		 * 
		 * @param type 数据集类型
		 * @return
		 */
		public static boolean isValidType(DatasetType type) {
			initialize();
			boolean result = true;
			if (datasetTypes.get(type) == null) {
				result = false;
			}
			// return Enum.IsDefined(typeof(DatasetType), type);
			return result;
		}

		public static boolean isPoint(DatasetType type) {
			boolean result = false;
			try {
				if (type == DatasetType.POINT || type == DatasetType.POINT3D) {
					result = true;
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return result;
		}

		public static boolean isLine(DatasetType type) {
			boolean result = false;
			try {
				if (type == DatasetType.LINE || type == DatasetType.LINEM || type == DatasetType.LINE3D || type == DatasetType.NETWORK
						|| type == DatasetType.NETWORK3D) {
					result = true;
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return result;
		}

		public static boolean isRegion(DatasetType type) {
			boolean result = false;
			try {
				if (type == DatasetType.REGION || type == DatasetType.REGION3D) {
					result = true;
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return result;
		}
	}

	public static class DatasetWrap {

		// #region Function_Public
		// /// <summary>
		// /// 触发创建影像金字塔事件
		// /// </summary>
		// /// <param name="newWindowType"></param>
		// /// <returns></returns>
		// public static boolean SendBuildPyramidEvent(Dataset dataset)
		// {
		// boolean result = false;
		// try
		// {
		// if (dataset != null
		// && (dataset.getType() == DatasetType.Grid
		// || dataset.getType() == DatasetType.GridCollection
		// || dataset.getType() == DatasetType.Image
		// || dataset.getType() == DatasetType.ImageCollection))
		// {
		// BuildPyramidEventArgs arg = new BuildPyramidEventArgs(dataset);
		// BuildPyramidEvent(null, arg);
		// result = arg.Handled;
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return result;
		// }

		// / <summary>
		// /
		// / </summary>

		/**
		 * 关闭数据集
		 * 
		 * @param datasetNames 需要删除的数据集名称
		 */
		public static void CloseDataset(Dataset[] closeDataset) {
			try {
				if (closeDataset == null || closeDataset.length <= 0) {
					return;
				}
				if (null != Application.getActiveApplication().getMainFrame().getFormManager()
						&& 0 < Application.getActiveApplication().getMainFrame().getFormManager().getCount()) {
					// 删除时考虑地图与场景

					int formNumber = Application.getActiveApplication().getMainFrame().getFormManager().getCount();
					for (int i = 0; i < formNumber; i++) {
						IForm form = Application.getActiveApplication().getMainFrame().getFormManager().get(i);
						if (form instanceof IFormMap) {
							Map map = ((IFormMap) form).getMapControl().getMap();
							Layers layers = map.getLayers();
							for (int j = 0; j < closeDataset.length; j++) {
								layers.removeByDataset(closeDataset[j]);
							}
							map.refresh();
						} else if (form instanceof IFormScene) {
							Scene scene = ((IFormScene) form).getSceneControl().getScene();
							TerrainLayers terrainLayers = scene.getTerrainLayers();
							Layer3Ds layer3Ds = scene.getLayers();
							for (int j = 0; j < closeDataset.length; j++) {
								// 移除地形图层
								for (int k = 0; k < terrainLayers.getCount(); k++) {
									if (closeDataset[j] == terrainLayers.get(k).getDataset()) {
										terrainLayers.remove(k);
										k--;
									}
								}
								// 移除普通图层
								for (int k = 0; k < layer3Ds.getCount(); k++) {
									if (layer3Ds.get(k) instanceof Layer3DDataset) {
										if (closeDataset[j] == ((Layer3DDataset) layer3Ds.get(k)).getDataset()) {
											layer3Ds.remove(k);
											k--;
										}
									}
								}
							}
							scene.refresh();
						} else if (form instanceof IFormTabular) {
							Dataset dataset = ((IFormTabular) form).getRecordset().getDataset();
							for (int j = 0; j < closeDataset.length; j++) {
								if (closeDataset[j].equals(dataset)) {
									Application.getActiveApplication().getMainFrame().getFormManager().close(form);
									i--;
									formNumber--;
									break;
								}
							}
						}
					}
				}
				return;
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		/**
		 * 关闭数据集
		 * 
		 * @param closeDatasets ：需要关闭的数据集集合类
		 */
		public static void CloseDataset(Datasets closeDatasets) {
			if (null == closeDatasets || 0 == closeDatasets.getCount()) {
				return;
			}
			Dataset[] datasets = new Dataset[closeDatasets.getCount()];
			for (int i = 0; i < closeDatasets.getCount(); i++) {
				datasets[i] = closeDatasets.get(i);
			}
			CloseDataset(datasets);
		}

		public static Dataset getDatasetFromDatasource(String datasetName, Datasource datasource) {
			Dataset result = null;
			try {
				Datasets datasets = datasource.getDatasets();
				for (int j = 0; j < datasets.getCount(); j++) {
					if (datasets.get(j).getName().equals(datasetName)) {
						result = datasets.get(datasetName);
					}

				}
			} catch (Exception e) {
				Application.getActiveApplication().getOutput().output(e);
			}
			return result;
		}

		//

		/**
		 * 根据已有的数据集名，获取指定前缀字符串的唯一数据集名
		 * 
		 * @param datasetName 指定的数据集名称
		 * @param allDatasetNames 即将增加的数据集的名称
		 * @return 可用数据集名称
		 */
		public static String getAvailableDatasetName(String datasetName, String[] allDatasetNames) {
			String availableMapName = "";
			try {
				if (datasetName.length() == 0) {
					datasetName = "Dataset";
				}

				String tempName = "";
				tempName = datasetName.toLowerCase();
				if (allDatasetNames.length > 0) {
					ArrayList<String> datasetNames = new ArrayList<String>();
					for (int index = 0; index < allDatasetNames.length; index++) {
						datasetNames.add(allDatasetNames[index].toLowerCase());
					}

					if (!datasetNames.contains(tempName)) {
						availableMapName = datasetName;
					} else {
						int indexMapName = 1;
						while (true) {
							availableMapName = String.format("%s_%d", datasetName, indexMapName);
							tempName = availableMapName.toLowerCase();
							if (!datasetNames.contains(tempName)) {
								break;
							}

							indexMapName += 1;
						}
					}
				} else {
					availableMapName = datasetName;
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return availableMapName;
		}

		/**
		 * 根据已有的数据源和即将创建的数据集，获取指定前缀字符串的唯一数据集名
		 * 
		 * @param datasource 保存数据集的数据源
		 * @param datasetName 指定的数据集名称
		 * @param allDatasetNames 即将增加的数据集的名称
		 * @return 可用数据集名称
		 */
		public static String getAvailableDatasetName(Datasource datasource, String datasetName, String[] newDatasetNames) {
			String availableMapName = "";
			try {
				if (datasetName.length() == 0) {
					datasetName = "Dataset";
				}

				ArrayList<String> datasetNames = new ArrayList<String>();
				for (int index = 0; index < datasource.getDatasets().getCount(); index++) {
					Dataset dataset = datasource.getDatasets().get(index);
					datasetNames.add(dataset.getName().toLowerCase());
				}

				for (int index = 0; index < newDatasetNames.length; index++) {
					datasetNames.add(newDatasetNames[index].toLowerCase());
				}

				String tempName = "";
				tempName = datasetName.toLowerCase();
				if (datasetNames.size() > 0) {
					if (!datasetNames.contains(tempName)) {
						availableMapName = datasetName;
					} else {
						int indexMapName = 1;
						while (true) {
							availableMapName = String.format("%s_%d", datasetName, indexMapName);
							tempName = availableMapName.toLowerCase();
							if (!datasetNames.contains(tempName)) {
								break;
							}

							indexMapName += 1;
						}
					}
				} else {
					availableMapName = datasetName;
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return availableMapName;
		}

		// /// <summary>
		// /// 创建矢量数据集，并采用源数据的参数设置
		// /// </summary>
		// /// <param name="srcDataset">源数据集</param>
		// /// <param name="desDatasource">目标数据源</param>
		// /// <param name="strDTName">目标数据集名称</param>
		// /// <param name="type">要创建的数据集类型</param>
		// /// <returns></returns>
		// public static DatasetVector CreatDatasetVector(DatasetVector
		// srcDataset, Datasource desDatasource, String strDTName, DatasetType
		// type)
		// {
		// DatasetVector resultDataset = null;
		//
		// try
		// {
		// DatasetVectorInfo info = new DatasetVectorInfo();
		// info.Name =
		// desDatasource.Datasets.getAvailableDatasetName(strDTName);
		// info.getType() = type;
		// //考虑一下不支持编码的数据集类型的感受 added by zengwh 2012/6/13
		// if (type == DatasetType.Point || type == DatasetType.Tabular || type
		// == DatasetType.CAD ||
		// type == DatasetType.Line3D || type == DatasetType.Point3D || type ==
		// DatasetType.Region3D)
		// {
		// info.EncodeType = EncodeType.None;
		// }
		// else
		// {
		// if (srcDataset != null)
		// {
		//
		// info.EncodeType = srcDataset.EncodeType;
		// }
		// }
		//
		// resultDataset = desDatasource.Datasets.Create(info);
		// if (resultDataset != null)
		// {
		// if (srcDataset != null)
		// {
		// resultDataset.PrjCoordSys = srcDataset.PrjCoordSys;
		// resultDataset.Charset = srcDataset.Charset;
		// // 非系统字段处理
		// FieldInfo field = new FieldInfo();
		// foreach (FieldInfo fieldinfo in srcDataset.FieldInfos)
		// {
		// if (!fieldinfo.IsSystemField)
		// {
		// if (!resultDataset.FieldInfos.Contains(fieldinfo.Caption))
		// {
		// field.Name = resultDataset.getAvailableFieldName(fieldinfo.Caption);
		// field.getType() = fieldinfo.getType();
		// field.DefaultValue = fieldinfo.DefaultValue;
		// field.IsRequired = fieldinfo.IsRequired;
		// field.MaxLength = fieldinfo.MaxLength;
		// field.Caption = fieldinfo.Caption;
		// resultDataset.FieldInfos.Add(field);
		// }
		// }
		// }
		// }
		// }
		//
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return resultDataset;
		// }
		//
		// private static FunctionID getFunID(DatasetType type)
		// {
		// FunctionID funID = FunctionID.None;
		// switch (type)
		// {
		// case DatasetType.CAD:
		// funID = FunctionID.DeleteCADDataset;
		// break;
		// case DatasetType.Grid:
		// funID = FunctionID.DeleteGridDataset;
		// break;
		// case DatasetType.GridCollection:
		// funID = FunctionID.DeleteGridCollectionDataset;
		// break;
		// case DatasetType.Image:
		// funID = FunctionID.DeleteImageDataset;
		// break;
		// case DatasetType.ImageCollection:
		// funID = FunctionID.DeleteImageCollectionDataset;
		// break;
		// case DatasetType.Line:
		// funID = FunctionID.DeleteLineDataset;
		// break;
		// case DatasetType.Line3D:
		// funID = FunctionID.DeleteLine3DDataset;
		// break;
		// case DatasetType.LineM:
		// funID = FunctionID.DeleteLineMDataset;
		// break;
		// case DatasetType.LinkTable:
		// funID = FunctionID.DeleteLinkTableDataset;
		// break;
		// case DatasetType.Network:
		// funID = FunctionID.DeleteNetworkDataset;
		// break;
		// case DatasetType.ParametricLine:
		// funID = FunctionID.DeleteParametricLineDataset;
		// break;
		// case DatasetType.ParametricRegion:
		// funID = FunctionID.DeleteParametricRegionDataset;
		// break;
		// case DatasetType.Point:
		// funID = FunctionID.DeletePointDataset;
		// break;
		// case DatasetType.Point3D:
		// funID = FunctionID.DeletePoint3DDataset;
		// break;
		// case DatasetType.Region:
		// funID = FunctionID.DeleteRegionDataset;
		// break;
		// case DatasetType.Region3D:
		// funID = FunctionID.DeleteRegion3DDataset;
		// break;
		// case DatasetType.Tabular:
		// funID = FunctionID.DeleteTabularDataset;
		// break;
		// case DatasetType.Text:
		// funID = FunctionID.DeleteTextDataset;
		// break;
		// case DatasetType.Topology:
		// funID = FunctionID.DeleteTopologyDataset;
		// break;
		// case DatasetType.WCS:
		// funID = FunctionID.DeleteTopologyDataset;
		// break;
		// case DatasetType.WMS:
		// funID = FunctionID.DeleteWMSDataset;
		// break;
		// }
		// return funID;
		// }
		//
		// /// <summary>
		// /// 删除指定的数据集
		// /// </summary>
		// /// <param
		// name="datasets">要删除的数据集。如果datasets中包含数据集集合对象，如影像数据集集合对象，那么将删除该集合对象中的所有子数据集。如果要使用删除数据集合中指定的数据集子项，请使用DeleteDatasetCollectionItems</param>
		// public static boolean DeleteDatasets(Dataset[] datasets)
		// {
		// boolean isDeleted = false;
		// FunctionID funID = FunctionID.None;
		// try
		// {
		// String message = String.Empty;
		// String text = String.Empty;
		//
		// message = CoreResources.String_DatasetDelete_Confirm;
		// if (datasets.Length == 1)
		// {
		// message = message + "\r\n" +
		// String.format(CoreResources.String_DatasetDelete_ConfirOne,
		// datasets[0].Datasource.Alias, datasets[0].Name);
		// }
		// else
		// {
		// message = message + "\r\n" +
		// String.format(CoreResources.String_DatasetDelete_ConfirMulti,
		// datasets.Length);
		// }
		// if (datasets[0].Datasource.IsReadOnly)
		// {
		// //只读数据源就不要弹出提示窗口了
		// message = String.format(CoreResources.String_DatasetDelete_ReadOnly,
		// datasets[0].Datasource.Alias);
		// MessageBox.Show(message, CoreResources.String_DatasetDelete,
		// MessageBoxButtons.OK, MessageBoxIcon.Error);
		// }
		// else
		// {
		// boolean isDynamicSegment = false;
		// List<Dataset> dynamicSegmentDatsets = new List<Dataset>();
		// for (int i = 0; i < datasets.Length; i++)
		// {
		// DynamicSegmentInfo[] info =
		// DynamicSegmentManager.getDynamicSegmentInfos(datasets.get(i) as
		// DatasetVector);
		// //info[0].getDatasetRole()
		// if (datasets.get(i) is DatasetVector &&
		// DynamicSegmentManager.getDynamicSegmentInfos(datasets.get(i) as
		// DatasetVector).Length > 0)
		// {
		// isDynamicSegment = true;
		// dynamicSegmentDatsets.Add(datasets.get(i));
		// }
		// }
		// if (isDynamicSegment)
		// {
		// String datasetsName = String.Empty;
		// for (int i = 0; i < dynamicSegmentDatsets.Count; i++)
		// {
		// datasetsName = datasetsName + "“" + dynamicSegmentDatsets.get(i).Name
		// + "”";
		// }
		// message =
		// String.format(CoreResources.String_IsDeleteDynamicSegmentDatasets,
		// datasetsName);
		// if (MessageBox.Show(message, CoreResources.String_MessageBox_Title,
		// MessageBoxButtons.YesNo) == DialogResult.Yes)
		// {
		// for (int i = 0; i < dynamicSegmentDatsets.Count; i++)
		// {
		// DynamicSegmentManager.RemoveDynamicSegmentInfos(dynamicSegmentDatsets.get(i)
		// as DatasetVector);
		// }
		// for (int i = datasets.Length - 1; i >= 0; i--)
		// {
		// String strAlias = datasets.get(i).Datasource.Alias;
		// String datasetName = datasets.get(i).Name;
		// funID = getFunID(datasets.get(i).getType());
		// if (datasets.get(i).Datasource.Datasets.Delete(datasets.get(i).Name))
		// {
		// message =
		// String.format(CoreResources.String_Delete_Dataset_Successed,
		// strAlias, datasetName);
		// }
		// else
		// {
		// message = String.format(CoreResources.String_Delete_Dataset_Failed,
		// strAlias, datasetName);
		//
		// }
		// Application.getActiveApplication().Output.Output(message);
		// }
		// }
		// }
		// else
		// {
		// if (MessageBox.Show(message, CoreResources.String_DatasetDelete,
		// MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) ==
		// DialogResult.OK)
		// {
		// text = String.Empty;
		// for (int i = datasets.Length - 1; i >= 0; i--)
		// {
		// Dataset dataset = datasets.get(i);
		// if (dataset != null)
		// {
		// //text = dataset.Name + "@" + dataset.Datasource.Alias;
		// String strAlias = dataset.Datasource.Alias;
		// String datasetName = dataset.Name;
		// funID = getFunID(dataset.getType());
		// if (dataset.Datasource.Datasets.Delete(dataset.Name))
		// {
		// message =
		// String.format(CoreResources.String_Delete_Dataset_Successed,
		// strAlias, datasetName);
		//
		// }
		// else
		// {
		// message = String.format(CoreResources.String_Delete_Dataset_Failed,
		// strAlias, datasetName);
		//
		// }
		// Application.getActiveApplication().Output.Output(message);
		// }
		// }
		// }
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return isDeleted;
		// }
		//
		// /// <summary>
		// /// 删除指定数据集集合对象中的子项
		// /// </summary>
		// /// <param
		// name="dataset">指定的数据集集合对象，目前组件提供的两种数据集集合：栅格数据集集合和影像数据集集合</param>
		// /// <param name="itemAlis">集合中需要删除的子项名称</param>
		// public static boolean DeleteDatasetCollectionItems(Dataset dataset,
		// String[] itemAlias)
		// {
		// boolean result = false;
		// try
		// {
		// if (dataset != null && itemAlias != null && itemAlias.Length > 0)
		// {
		// String message = CoreResources.String_DatasetDelete_Confirm;
		// if (dataset.Datasource.IsReadOnly)
		// {
		// //只读数据源就不要弹出提示窗口了
		// message = String.format(CoreResources.String_DatasetDelete_ReadOnly,
		// dataset.Datasource.Alias);
		// MessageBox.Show(message, CoreResources.String_DatasetDelete,
		// MessageBoxButtons.OK, MessageBoxIcon.Error);
		// }
		// else
		// {
		// DatasetGridCollection gridCollection = dataset as
		// DatasetGridCollection;
		// String datasetName = dataset.Name;
		// if (gridCollection != null)
		// {
		// if (itemAlias.Length == 1)
		// {
		// message = message + "\r\n" +
		// String.format(CoreResources.String_MSG_GRIDCOLLECTION_ITEREMOVE,
		// datasetName, itemAlias[0]);
		// }
		// else
		// {
		// message = message + "\r\n" +
		// String.format(CoreResources.String_MSG_GRIDCOLLECTION_ITEMS_REMOVE,
		// datasetName, itemAlias.Length);
		// }
		// if (MessageBox.Show(message, CoreResources.String_DatasetDelete,
		// MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) ==
		// DialogResult.OK)
		// {
		// result = true;
		// for (int i = 0; i < itemAlias.Length; i++)
		// {
		// if (gridCollection.Remove(itemAlias.get(i)))
		// {
		// message =
		// String.format(CoreResources.String_Delete_DatasetCollectionIteSuccessed,
		// datasetName, itemAlias.get(i));
		// }
		// else
		// {
		// result = false;
		// message =
		// String.format(CoreResources.String_Delete_DatasetCollectionIteFailed,
		// datasetName, itemAlias.get(i));
		// }
		// Application.getActiveApplication().Output.Output(message);
		// }
		// }
		// }
		// else
		// {
		// DatasetImageCollection imageCollection = dataset as
		// DatasetImageCollection;
		// if (imageCollection != null)
		// {
		// if (itemAlias.Length == 1)
		// {
		// message = message + "\r\n" +
		// String.format(CoreResources.String_MSG_IMAGECOLLECTION_ITEREMOVE,
		// datasetName, itemAlias[0]);
		// }
		// else
		// {
		// message = message + "\r\n" +
		// String.format(CoreResources.String_MSG_IMAGECOLLECTION_ITEMS_REMOVE,
		// datasetName, itemAlias.Length);
		// }
		// if (MessageBox.Show(message, CoreResources.String_DatasetDelete,
		// MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) ==
		// DialogResult.OK)
		// {
		// result = true;
		// for (int i = 0; i < itemAlias.Length; i++)
		// {
		// if (imageCollection.Remove(itemAlias.get(i)))
		// {
		// message =
		// String.format(CoreResources.String_Delete_DatasetCollectionIteSuccessed,
		// datasetName, itemAlias.get(i));
		// }
		// else
		// {
		// result = false;
		// message =
		// String.format(CoreResources.String_Delete_DatasetCollectionIteFailed,
		// datasetName, itemAlias.get(i));
		// }
		// Application.getActiveApplication().Output.Output(message);
		// }
		// }
		// }
		// }
		//
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return result;
		// }
		//
		// /// <summary>
		// /// 获取不同引擎下不同数据集类型支持的空间索引类型
		// /// </summary>
		// /// <param name="datasetVector"></param>
		// /// <returns></returns>
		// public static List<SpatialIndexType>
		// getDatasetSupportSpatialIndexTypes(DatasetVector datasetVector)
		// {
		// List<SpatialIndexType> result = new List<SpatialIndexType>();
		// try
		// {
		// if (datasetVector.IsSpatialIndexTypeSupported(SpatialIndexType.None))
		// {
		// result.Add(SpatialIndexType.None);
		// }
		// if
		// (datasetVector.IsSpatialIndexTypeSupported(SpatialIndexType.RTree))
		// {
		// result.Add(SpatialIndexType.RTree);
		// }
		// if
		// (datasetVector.IsSpatialIndexTypeSupported(SpatialIndexType.QTree))
		// {
		// result.Add(SpatialIndexType.QTree);
		// }
		// if
		// (datasetVector.IsSpatialIndexTypeSupported(SpatialIndexType.MultiLevelGrid))
		// {
		// result.Add(SpatialIndexType.MultiLevelGrid);
		// }
		// if (datasetVector.IsSpatialIndexTypeSupported(SpatialIndexType.Tile))
		// {
		// result.Add(SpatialIndexType.Tile);
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return result;
		// }
		//
		// public static DatasetGroup getParentGroup(Dataset dataset)
		// {
		// DatasetGroup result = null;
		// if (dataset != null)
		// {
		// DatasetGroups groups = dataset.Datasource.RootGroup.ChildGroups;
		// for (int i = 0; i < groups.Count; i++)
		// {
		// if (groups.get(i).IndexOf(dataset.Name) >= 0)
		// {
		// result = groups.get(i);
		// break;
		// }
		// }
		// }
		// return result;
		// }
		// #endregion
		//
		// #region Function_Event
		//
		// #endregion
		//
		// #region Function_Private
		//
		// #endregion
		//
		// #region Event
		//
		// #endregion
		//
		// #region InterfaceMembers
		//
		// #endregion
		//
		// #region NestedTypes
		//
		// #endregion
		// }
		//
		// public static event BuildPyramidEventHandler BuildPyramidEvent;
		// public delegate void BuildPyramidEventHandler(Object sender,
		// BuildPyramidEventArgs e);
		// public class BuildPyramidEventArgs : EventArgs
		// {
		// private Dataset dataset;
		// public Dataset Dataset
		// {
		// get
		// {
		// return dataset;
		// }
		// }
		//
		// private boolean handled;
		// public boolean Handled
		// {
		// get
		// {
		// return handled;
		// }
		// set
		// {
		// handled = value;
		// }
		// }
		//
		// public BuildPyramidEventArgs(Dataset dataset)
		// {
		// dataset = dataset;
		// }
		// }
	}

	public static class DatasourceWrap {

		// #region Variable
		// private static DataTable CurrentDataTable;

		private static ArrayList<EngineInfo> loadedFileEngines = null;
		public static PluginInfo pluginInfo = null;
		public static SmMenu recentDatasourceMenu = null;

		/**
		 * 刚刚打开失败的数据源，是不是因为密码错误
		 */
		private static boolean passwordWrong = false;

		public static boolean isPasswordWrong() {
			return passwordWrong;
		}

		// private static EngineType[] fileEngineTypes;
		// private static EngineType[] databaseEngineTypes;
		// private static EngineType[] webEngineTypes;
		// #endregion

		/**
		 * 打开指定路径与密码的文件型数据源
		 * 
		 * @param fileName
		 * @param passWord
		 * @param isReadOnly
		 * @return
		 */
		public static Datasource openFileDatasource(String fileName, String passWord, boolean isReadOnly) {
			Datasource datasource = null;
			Workspace workspace = Application.getActiveApplication().getWorkspace();
			try {
				((JFrame) Application.getActiveApplication().getMainFrame()).setCursor(Cursor.WAIT_CURSOR);
				DatasourceConnectionInfo info = new DatasourceConnectionInfo();

				// 看看该文件是否已经打开了
				boolean alreadyOpen = false;
				String server = "";
				String fileNameTemp = fileName.toLowerCase();
				fileNameTemp = fileNameTemp.replace("\\", "/");
				for (int index = 0; index < workspace.getDatasources().getCount(); index++) {
					server = workspace.getDatasources().get(index).getConnectionInfo().getServer().toLowerCase();
					server = server.replace("\\", "/");
					if (server.indexOf(".") > -1) {
						if (server.equals(fileNameTemp) || (server.substring(0, server.lastIndexOf(".")) + ".udd").equals(fileNameTemp)
								|| (server.substring(0, server.lastIndexOf(".")) + ".udb").equals(fileNameTemp)) {
							datasource = workspace.getDatasources().get(index);
							alreadyOpen = true;
							break;
						}
					}
				}

				if (!alreadyOpen) {
					File file = new File(fileName);
					String alias = file.getName();
					String fileExt = "udb";
					int dot = alias.lastIndexOf('.');
					if ((dot > -1) && (dot < (alias.length()))) {
						fileExt = alias.substring(dot, alias.length());
						alias = alias.substring(0, dot);
					}

					// 找一个合适的别名
					alias = getAvailableDatasourceAlias(alias, 0);

					info.setAlias(alias);
					info.setServer(fileName);
					info.setPassword(passWord);
					info.setEngineType(CommonToolkit.EngineTypeWrap.getEngineType(fileExt));
					info.setReadOnly(!file.canWrite() || isReadOnly || info.getEngineType() == EngineType.VECTORFILE);

					try {
						datasource = workspace.getDatasources().open(info);
						if (datasource != null) {
							// 数据源打开成功后将其添加到最近文件列表中 [12/12/2011 zhoujt]
							addDatasourceToRecentFile(datasource);
						}
					} catch (Exception ex) {
						if (ex.getMessage().equalsIgnoreCase("supermap_license_error_wronglicensedata")) {
							Application.getActiveApplication().getOutput().output(CoreProperties.getString("String_Wronglicensedata"));
						}
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			} finally {
				((JFrame) Application.getActiveApplication().getMainFrame()).setCursor(Cursor.DEFAULT_CURSOR);
			}

			return datasource;
		}

		public static Datasource openFileDatasource(String fileName, String passWord, boolean isReadOnly, boolean isFirst) {
			DatasourceWrap.passwordWrong = false;
			Datasource datasource = null;
			try {
				((JFrame) Application.getActiveApplication().getMainFrame()).setCursor(Cursor.WAIT_CURSOR);
				Toolkit.clearErrors();
				datasource = openFileDatasource(fileName, passWord, isReadOnly);
				if (datasource == null) {
					ErrorInfo[] errorInfos = Toolkit.getLastErrors(1);

					// 首先判断一下是不是已知的错误，目前已知的就是密码错误
					for (int i = 0; i < errorInfos.length; i++) {
						if (errorInfos[i].getMarker().equals(CoreProperties.getString("String_UGS_PASSWORD"))
								|| errorInfos[i].getMarker().equals(CoreProperties.getString("String_UGS_PASSWORDError"))) {
							DatasourceWrap.passwordWrong = true;
							break;
						}
					}

					// 不是第一次打开，输出错误信息
					if (!isFirst) {
						if (DatasourceWrap.passwordWrong) {
							Application.getActiveApplication().getOutput().output(CoreProperties.getString("String_CurrentPasswordWrong"));
						} else {
							for (int i = 0; i < errorInfos.length; i++) {
								Application.getActiveApplication().getOutput().output(errorInfos[i].getMessage());
							}
						}
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			} finally {
				((JFrame) Application.getActiveApplication().getMainFrame()).setCursor(Cursor.DEFAULT_CURSOR);
			}

			return datasource;
		}

		// // 关闭相应的数据源
		// public static void CloseDatasources(Datasource[] datasources)
		// {
		// try
		// {
		// String strdatasourceAlias = String.Empty;
		// String message = String.Empty;
		// if (datasources.Length == 1)
		// {
		// strdatasourceAlias = datasources[0].Alias;
		// }
		// else
		// {
		// for (int i = 0; i < datasources.Length; i++)
		// {
		// if (i == datasources.Length - 1)
		// {
		// strdatasourceAlias +=
		// Properties.CoreResources.String_QuotationMarkHead +
		// datasources[i].Alias +
		// Properties.CoreResources.String_QuotationMarkEnd;
		// }
		// else
		// {
		// strdatasourceAlias +=
		// Properties.CoreResources.String_QuotationMarkHead +
		// datasources[i].Alias +
		// Properties.CoreResources.String_QuotationMarkEnd +
		// Properties.CoreResources.String_IntervalMark;
		// }
		// }
		// }
		// Application.ActiveApplication.UserInfoManage.FunctionRun(FunctionID.CloseDatasource);//加入用户体验计划
		// message =
		// String.Format(Properties.CoreResources.String_MessageBox_CloseDatasource,
		// strdatasourceAlias);
		//
		// if (MessageBox.Show(message, UI.CommonToolkit.GetMessageBoxTitle(),
		// MessageBoxButtons.OKCancel, MessageBoxIcon.Information) ==
		// DialogResult.OK)
		// {
		// for (int i = datasources.Length - 1; i >= 0; i--)
		// {
		// Application.ActiveApplication.UserInfoManage.FunctionStart(FunctionID.CloseDatasource);
		// try
		// {
		// boolean result =
		// Application.ActiveApplication.Workspace.Datasources.Close(datasources[i].Alias);
		//
		// if (result)
		// {
		// Application.ActiveApplication.UserInfoManage.FunctionSuccess(FunctionID.CloseDatasource);
		// }
		// else
		// {
		// Application.ActiveApplication.UserInfoManage.FunctionFailed(FunctionID.CloseDatasource);
		// }
		// }
		// catch (Exception ex)
		// {
		// Application.ActiveApplication.Output.Output(ex, InfoType.Exception,
		// FunctionID.CloseDatasource);
		// }
		// }
		// }
		// }
		// catch
		// {
		//
		// }
		// }
		//

		/**
		 * 将指定数据源添加到最近文件列表中
		 * 
		 * @param datasource
		 */
		public static void addDatasourceToRecentFile(Datasource datasource) {
			try {
				if (datasource != null) {
					String filePath = datasource.getConnectionInfo().getServer().replace("\\", "/");
					// File file = new File(filePath);

					if (recentDatasourceMenu != null) {
						removeRecentFile(filePath);

						XMLCommand xmlCommand = new XMLCommand(pluginInfo);
						xmlCommand.setCtrlActionClass("CtrlActionRecentFiles");
						xmlCommand.setLabel(filePath);
						xmlCommand.setTooltip(filePath);
						SmMenuItem menuItem = new SmMenuItem(null, xmlCommand, recentDatasourceMenu);
						if (menuItem != null) {
							recentDatasourceMenu.insert((IBaseItem) menuItem, 0);
							if (recentDatasourceMenu.getItemCount() > 7) {
								removeRecentFile(((SmMenuItem) recentDatasourceMenu.getItem(7)).getText());
							}
							saveRecentFile(filePath);
						}
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
		}

		public static void initRecentFileMenu() {
			try {
				String recentFilePath = PathUtilties.getFullPathName(_XMLTag.g_RecentFileXML, false);
				File file = new File(recentFilePath);
				if (file.exists()) {
					Element element = XmlUtilties.getRootNode(recentFilePath);
					if (element != null) {
						NodeList nodes = element.getChildNodes();
						for (int i = 0; i < nodes.getLength(); i++) {
							if (nodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
								Element item = (Element) (nodes.item(i));
								if (item.getNodeName().equalsIgnoreCase(_XMLTag.g_NodeGroup)) {
									String type = item.getAttribute(_XMLTag.g_ControlLabel);
									if (type.equalsIgnoreCase(CoreProperties.getString("String_RecentDatasource"))) {
										NodeList childnNodes = item.getChildNodes();
										for (int j = 0; j < childnNodes.getLength(); j++) {
											if (childnNodes.item(j).getNodeType() == Node.ELEMENT_NODE) {
												Element childItem = (Element) (childnNodes.item(j));
												String filePath = childItem.getAttribute(_XMLTag.g_NodeContent);
												XMLCommand xmlCommand = new XMLCommand(pluginInfo);
												xmlCommand.setCtrlActionClass("CtrlActionRecentFiles");
												xmlCommand.setLabel(filePath);
												xmlCommand.setTooltip(filePath);
												SmMenuItem menuItem = new SmMenuItem(null, xmlCommand, recentDatasourceMenu);
												if (menuItem != null) {
													recentDatasourceMenu.add((IBaseItem) menuItem);
												}
											}
										}
									}
								}
							}
						}
					}
				}

			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
		}

		public static void saveRecentFile(String filePath) {
			try {
				String recentFilePath = PathUtilties.getFullPathName(_XMLTag.g_RecentFileXML, false);
				File file = new File(recentFilePath);
				if (file.exists()) {
					Document document = XmlUtilties.getDocument(recentFilePath);
					Element element = document.getDocumentElement();
					if (element != null) {
						NodeList nodes = element.getChildNodes();
						for (int i = 0; i < nodes.getLength(); i++) {
							if (nodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
								Element item = (Element) (nodes.item(i));
								if (item.getNodeName().equalsIgnoreCase(_XMLTag.g_NodeGroup)) {
									String type = item.getAttribute(_XMLTag.g_ControlLabel);
									if (type.equalsIgnoreCase(CoreProperties.getString("String_RecentDatasource"))) {
										// 把原来的记录全部取出来保存
										NodeList childnNodes = item.getChildNodes();
										ArrayList<String> recentFiles = new ArrayList<String>();
										for (int j = childnNodes.getLength() - 1; j >= 0; j--) {
											if (childnNodes.item(j).getNodeType() == Node.ELEMENT_NODE) {
												Element childItem = (Element) (childnNodes.item(j));
												recentFiles.add(0, childItem.getAttribute(_XMLTag.g_NodeContent));
											}
											item.removeChild(childnNodes.item(j));
										}

										// 添加新纪录
										Element newItem = document.createElement("item");
										newItem.setAttribute(_XMLTag.g_NodeContent, filePath);
										item.appendChild(newItem);

										// 把之前的记录再写入
										for (int j = 0; j < recentFiles.size(); j++) {
											newItem = document.createElement("item");
											newItem.setAttribute(_XMLTag.g_NodeContent, recentFiles.get(j));
											item.appendChild(newItem);
										}

										// 保存文件
										try {
											XmlUtilties.saveXml(recentFilePath, (Node) document, document.getXmlEncoding());
										} catch (Exception e) {
											Application.getActiveApplication().getOutput().output(e);
										}

										break;
									}
								}
							}
						}
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
		}

		public static void removeRecentFile(String filePath) {
			try {
				for (IBaseItem item : recentDatasourceMenu.items()) {
					if (((SmMenuItem) item).getToolTipText().equals(filePath)) {
						recentDatasourceMenu.remove((IBaseItem) item);
					}
				}

				String recentFilePath = PathUtilties.getFullPathName(_XMLTag.g_RecentFileXML, false);
				File file = new File(recentFilePath);
				if (file.exists()) {
					Document document = XmlUtilties.getDocument(recentFilePath);
					Element element = document.getDocumentElement();
					if (element != null) {
						NodeList nodes = element.getChildNodes();
						for (int i = 0; i < nodes.getLength(); i++) {
							if (nodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
								Element item = (Element) (nodes.item(i));
								if (item.getNodeName().equalsIgnoreCase(_XMLTag.g_NodeGroup)) {
									String type = item.getAttribute(_XMLTag.g_ControlLabel);
									if (type.equalsIgnoreCase(CoreProperties.getString("String_RecentDatasource"))) {
										NodeList childnNodes = item.getChildNodes();
										for (int j = 0; j < childnNodes.getLength(); j++) {
											if (childnNodes.item(j).getNodeType() == Node.ELEMENT_NODE) {
												Element childItem = (Element) (childnNodes.item(j));
												String itemPath = childItem.getAttribute(_XMLTag.g_NodeContent);
												if (itemPath.equalsIgnoreCase(filePath)) {
													item.removeChild(childnNodes.item(j));
												}
											}
										}

										// 保存文件
										try {
											XmlUtilties.saveXml(recentFilePath, (Node) document, document.getXmlEncoding());
										} catch (Exception e) {
											Application.getActiveApplication().getOutput().output(e);
										}

										break;
									}
								}
							}
						}
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
		}

		public static String getAvailableDatasourceAlias(String alias, int index) {
			String availableName = alias;
			try {
				Datasource datasource = null;
				if (index == 0) {
					datasource = Application.getActiveApplication().getWorkspace().getDatasources().get(availableName);
				} else {
					availableName += "_" + String.valueOf(index);
					datasource = Application.getActiveApplication().getWorkspace().getDatasources().get(availableName);
				}

				if (datasource != null) {
					index++;

					availableName = getAvailableDatasourceAlias(alias, index);
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}

			return availableName;
		}

		//
		// #region Property
		// /// <summary>
		// /// 获取本地网络中SQL Server实例的信息列表 [1/6/2012 zhoujt]
		// /// </summary>
		// public static DataTable CurrentDataTable
		// {
		// get
		// {
		// if (CurrentDataTable == null)
		// {
		// getCurrentDataTable();
		// }
		// return CurrentDataTable;
		// }
		// set
		// {
		// CurrentDataTable = value;
		// }
		// }
		// #endregion
		//
		// #region Construct
		// static DatasourceWrap()
		// {
		// Initialize();
		// }
		// #endregion
		//
		// #region Function_Public
		// /// <summary>
		// /// 获取本地网络中SQL Server实例的信息列表 [1/6/2012 zhoujt]
		// /// </summary>
		// public static void getCurrentDataTable()
		// {
		// SqlDataSourceEnumerator enumerator =
		// SqlDataSourceEnumerator.Instance;
		// CurrentDataTable = enumerator.getDataSources();
		// }
		//
		// /// <summary>
		// /// 判断指定的文件后缀是否支持的文件引擎类型
		// /// </summary>
		// public static boolean IsSuportedFileEngineExt(String fileExt)
		// {
		// boolean result = false;
		//
		// EngineInfo[] loadedFileEngines = getLoadedFileEngines();
		// if (loadedFileEngines != null)
		// {
		// foreach (EngineInfo engInfo in loadedFileEngines)
		// {
		// foreach (String ext in engInfo.SupportExtensions)
		// {
		// if (String.Compare(fileExt, ext, true) == 0)
		// {
		// result = true;
		// break;
		// }
		// }
		// if (result)
		// {
		// break;
		// }
		// }
		// }
		// return result;
		// }

		/**
		 * 获取当前组件支持加载打开的文件引擎信息集合
		 * 
		 * @return 文件引擎信息集合
		 */
		public static EngineInfo[] getLoadedFileEngines() {
			EngineInfo[] result = null;
			try {
				if (loadedFileEngines == null) {
					loadedFileEngines = new ArrayList<EngineInfo>();
					// modify by huchenpu 2015-07-09
					// 组件有问题，下面这行代码直接抛异常
					// EngineInfo[] infos =
					// Environment.getCurrentLoadedEngineInfos();
					// int length = infos.length;
					// for (EngineInfo engInfo :
					// Environment.getCurrentLoadedEngineInfos()) {
					// if (engInfo.getEngineFamily() == EngineFamilyType.FILE) {
					// loadedFileEngines.add(engInfo);
					// }
					// }

					result = loadedFileEngines.toArray(new EngineInfo[loadedFileEngines.size()]);
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}

			return result;
		}

		// /// <summary>
		// /// 获取当前组件支持的某种数据源的所有引擎类型集合
		// /// </summary>
		// public static void Initialize()
		// {
		// List<EngineType> fileEngines = new List<EngineType>();
		// List<EngineType> databaseEngines = new List<EngineType>();
		// List<EngineType> webEngines = new List<EngineType>();
		// try
		// {
		// for (int i = 0; i <
		// SuperMap.Data.Environment.CurrentLoadedEngineInfos.Length; i++)
		// {
		// if
		// (SuperMap.Data.Environment.CurrentLoadedEngineInfos.get(i).EngineFamily
		// == EngineFamilyType.File)
		// {
		// fileEngines.Add(SuperMap.Data.Environment.CurrentLoadedEngineInfos.get(i).getType());
		// }
		// else if
		// (SuperMap.Data.Environment.CurrentLoadedEngineInfos.get(i).EngineFamily
		// == EngineFamilyType.Database)
		// {
		// databaseEngines.Add(SuperMap.Data.Environment.CurrentLoadedEngineInfos.get(i).getType());
		// }
		// else if
		// (SuperMap.Data.Environment.CurrentLoadedEngineInfos.get(i).EngineFamily
		// == EngineFamilyType.Web)
		// {
		// webEngines.Add(SuperMap.Data.Environment.CurrentLoadedEngineInfos.get(i).getType());
		// }
		// }
		// fileEngineTypes = fileEngines.ToArray();
		// databaseEngineTypes = databaseEngines.ToArray();
		// webEngineTypes = webEngines.ToArray();
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// }
		//
		// /// <summary>
		// /// 判断指定数据源是否文件数据源
		// /// </summary>
		// public static boolean IsFileDatasource(Datasource datasource)
		// {
		// boolean result = false;
		//
		// try
		// {
		// EngineInfo[] loadedFileEngines = getLoadedFileEngines();
		// if (loadedFileEngines != null)
		// {
		// foreach (EngineInfo engInfo in loadedFileEngines)
		// {
		// if (engInfo.getType() == datasource.EngineType)
		// {
		// result = true;
		// break;
		// }
		// }
		// }
		// }
		// catch
		// {
		//
		// }
		// return result;
		// }
		//
		// /// <summary>
		// /// 判断指定数据源是Web型数据源
		// /// </summary>
		// public static boolean IsWebDatasource(EngineType engineType)
		// {
		// boolean result = false;
		// try
		// {
		// for (int i = 0; i < webEngineTypes.Length ; i++)
		// {
		// if (webEngineTypes.get(i) == engineType)
		// {
		// result = true;
		// break;
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return result;
		// }
		/**
		 * 关闭所有内存数据源
		 */
		public static void CloseMemoryDatasource() {
			for (int i = 0; i < Application.getActiveApplication().getWorkspace().getDatasources().getCount();) {
				Datasource item = Application.getActiveApplication().getWorkspace().getDatasources().get(i);
				if (item.getConnectionInfo().getServer().equalsIgnoreCase(":memory:")) {
					Application.getActiveApplication().getWorkspace().getDatasources().close(item.getAlias());
					// 关闭内存数据源时不保存工作空间
					// Application.getActiveApplication().getWorkspace().Save();
				} else {
					i++;
				}
			}
		}

		/**
		 * 判断工作空间中是否存在内存数据源
		 * 
		 * @param workspace
		 * @return
		 */
		public static boolean isContianMemoryDatasource(Workspace workspace) {
			boolean isContian = false;
			try {
				for (int i = 0; i < workspace.getDatasources().getCount(); i++) {
					Datasource datasource = workspace.getDatasources().get(i);
					if (datasource.getConnectionInfo().getServer().equalsIgnoreCase(":memory:")) {
						isContian = true;
						break;
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return isContian;
		}

		/**
		 * 获取工作空间中的内存数据源
		 * 
		 * @param workspace
		 * @return
		 */
		public static String[] getMemoryDatasources(Workspace workspace) {
			ArrayList<String> datasources = new ArrayList<String>();
			try {
				for (int i = 0; i < workspace.getDatasources().getCount(); i++) {
					Datasource datasource = workspace.getDatasources().get(i);
					if (datasource.getConnectionInfo().getServer().equalsIgnoreCase(":memory:")) {
						datasources.add(datasource.getAlias());
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return datasources.toArray(new String[datasources.size()]);
		}
		//
		// /// <summary>
		// /// 将组件的文件引擎信息集合转化为桌面的文件引擎信息封装类，主要用于构造打开数据源对话框的过滤条件
		// /// </summary>
		// public static FileEngineInfo[] BuildFileEngineFilter(EngineInfo[]
		// loadedFileEngines)
		// {
		// List<FileEngineInfo> fileEngineInfos = new List<FileEngineInfo>();
		//
		// try
		// {
		// String fileExts = String.Empty;
		// String fileInfos = String.Empty;
		//
		// for (int i = loadedFileEngines.Length - 1; i >= 0; i--)
		// {
		// // 此处组件会增加引擎名称
		// // 另外组件还会增加判断是否是数据库型引擎的属性，所以到时此处也要增加判断才好
		//
		// EngineInfo engInfo = loadedFileEngines.get(i);
		// String fileExtTemp = String.Empty;
		//
		// FileEngineInfo fileEngineInfo = new FileEngineInfo();
		// fileEngineInfo.engineType = engInfo.getType();
		// fileEngineInfo.name = engInfo.Name;
		//
		// foreach (String fileExt in engInfo.SupportExtensions)
		// {
		// if (fileExt.Length > 0)
		// {
		// if (fileExt.toLowerCase().Equals(CoreResources.String_udd) ||
		// fileExt.toLowerCase().Equals(CoreResources.String_sdd))
		// {
		// }
		// else if (engInfo.getType() != EngineType.ImagePlugins)
		// {
		// if (fileExt.StartsWith(CoreResources.String_BitAndDot))
		// {
		// fileExtTemp += fileExt;
		// }
		// else if (fileExt.StartsWith(CoreResources.String_Dot))
		// {
		// fileExtTemp += String.format(CoreResources.String_Bit0, fileExt);
		// }
		// else
		// {
		// fileExtTemp += String.format(CoreResources.String_Bit0, fileExt);
		// }
		//
		// fileExtTemp += CoreResources.String_Separate;// ";";
		// }
		// else
		// {
		// String temp = String.Empty;
		// if (fileExt.StartsWith(CoreResources.String_BitAndDot))
		// {
		// temp = fileExt;
		// }
		// else if (fileExt.StartsWith(CoreResources.String_Dot))
		// {
		// temp = String.format(CoreResources.String_Bit0, fileExt);
		// }
		// else
		// {
		// temp = String.format(CoreResources.String_Bit0, fileExt);
		// }
		//
		// String strname =
		// CommonToolkit.UndefinedWrap.getImagePluginsName(temp);
		// fileInfos += strname;
		// fileExts = fileExts + temp + CoreResources.String_Separate;
		// fileInfos += String.format(CoreResources.String_MutiSeparate,
		// fileExtTemp);
		//
		// fileExtTemp = fileExts;
		// }
		// }
		// }
		//
		// if (fileExtTemp.Length > 0)
		// {
		// fileEngineInfo.fileExt = fileExtTemp;
		// fileEngineInfo.fileExt =
		// fileEngineInfo.fileExt.TrimEnd(CoreResources.String_Separate.ToCharArray());
		// fileEngineInfos.Add(fileEngineInfo);
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return fileEngineInfos.ToArray();
		// }
		//
		// /// <summary>
		// /// 根据桌面的文件引擎信息封装类构造打开数据源对话框的过滤条件
		// /// </summary>
		// public static String BuildLoadedFileEngineFilter(FileEngineInfo[]
		// fileEngineInfos)
		// {
		// String filter = String.Empty;
		//
		// try
		// {
		// String fileExts = String.Empty;
		// String fileInfos = String.Empty;
		// String allFilesFilter = String.Empty;
		//
		// foreach (FileEngineInfo fileEngineInfo in fileEngineInfos)
		// {
		// String temp = fileEngineInfo.fileExt.Replace(";*.sci3d", "");
		// temp = temp.Replace(";*.gdb", "");
		// fileExts += temp;
		// fileExts += CoreResources.String_Separate;
		// filter += fileEngineInfo.name;
		// filter += String.format(CoreResources.String_MutiSeparate, temp);
		// }
		//
		// allFilesFilter = String.format(CoreResources.String_AllFiles,
		// fileExts);
		//
		// filter = allFilesFilter + filter;
		// filter += "|";
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return filter;
		// }
		//
		// //static private String BuildLoadedFileEngineFilter()
		// //{
		// // String filter = String.Empty;
		// // EngineInfo[] loadedFileEngines = getLoadedFileEngines();
		// // if (loadedFileEngines != null)
		// // {
		// // FileEngineInfo[] fileEngineInfos =
		// BuildFileEngineFilter(loadedFileEngines);
		// // filter = BuildLoadedFileEngineFilter(fileEngineInfos);
		// // }
		//
		// // return filter;
		// //}
		// #endregion
		//
		// #region Function_Event
		//
		// #endregion
		//
		// #region Function_Private
		//
		// #endregion
		//
		// #region Event
		//
		// #endregion
		//
		// #region InterfaceMembers
		//
		// #endregion
		//
		// #region NestedTypes
		//
		// #endregion
		// }
		// }
		//
		// public class FileEngineInfo
		// {
		// public EngineType engineType;
		// public String fileExt;
		// public String name;
		// }
	}

	public static class DirectoryWrap {

		// public static Int64 getDirectorySize(String directoryPath)
		// {
		// Int64 size = 0;
		// if (!String.IsNullOrEmpty(directoryPath)
		// && Directory.Exists(directoryPath))
		// {
		// DirectoryInfo directoryInfo = new DirectoryInfo(directoryPath);
		// size = getDirectorySize(directoryInfo);
		// }
		//
		// return size;
		// }
		//
		// public static Int64 getDirectorySize(DirectoryInfo directoryInfo)
		// {
		// Int64 size = 0;
		// if (directoryInfo != null
		// && directoryInfo.Exists)
		// {
		// DirectoryInfo[] directoryInfos = directoryInfo.getDirectories();
		// for (int i = 0; i < directoryInfos.Length; i++)
		// {
		// size += getDirectorySize(directoryInfos.get(i));
		// }
		// FileInfo[] fileInfos = directoryInfo.getFiles();
		// for (int i = 0; i < fileInfos.Length; i++)
		// {
		// size += fileInfos.get(i).Length;
		// }
		// }
		//
		// return size;
		// }
		//
		// //将sourceDirectory下的所有文件以及文件夹复制到targetDirectory处
		// public static boolean Copy(String sourceDirectory, String
		// targetDirectory)
		// {
		// boolean result = false;
		// try
		// {
		// if (!String.IsNullOrEmpty(sourceDirectory)
		// && !String.IsNullOrEmpty(targetDirectory)
		// && Directory.Exists(sourceDirectory))
		// {
		// DirectoryInfo targetInfo = new DirectoryInfo(targetDirectory);
		// if (!targetInfo.Exists)
		// {
		// targetInfo.Create();
		// }
		//
		// String[] directorys = Directory.getDirectories(sourceDirectory);
		// for (int i = 0; i < directorys.Length; i++)
		// {
		// String directory = directorys.get(i);
		// DirectoryInfo directoryInfo = new DirectoryInfo(directory);
		// if ((directoryInfo.Attributes & FileAttributes.System) !=
		// FileAttributes.System
		// && (directoryInfo.Attributes & FileAttributes.Hidden) !=
		// FileAttributes.Hidden)
		// {
		// String subName = directoryInfo.Name;
		// DirectoryInfo targetSubInfo = targetInfo.CreateSubdirectory(subName);
		// if (!CommonToolkit.DirectoryWrap.Copy(directoryInfo.FullName,
		// targetSubInfo.FullName))
		// {
		// return false;
		// }
		// }
		// }
		// String[] files = Directory.getFiles(sourceDirectory);
		// for (int i = 0; i < files.Length; i++)
		// {
		// String sourceFile = files.get(i);
		// String fileName = Path.getFileName(sourceFile);
		// String targetFileName = targetDirectory + Path.DirectorySeparatorChar
		// + fileName;
		// File.Copy(sourceFile, targetFileName, true);
		// }
		// result = true;
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		//
		// return result;
		// }
		//
		// public static String getDirectoryName(String fullDirectoryName)
		// {
		// String directoryName = String.Empty;
		// if (!String.IsNullOrEmpty(fullDirectoryName))
		// {
		// try
		// {
		// DirectoryInfo directoryInfo = new DirectoryInfo(fullDirectoryName);
		// directoryName = directoryInfo.Name;
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// }
		//
		// return directoryName;
		// }
	}

	public static class DoubleWrap {

		// #region Variable
		// //private static LicenseMode g_LicenseMode;
		// //private static DateTime g_ExpiredDate;
		// //private static int LicenseTipMaxDays = 10;
		//
		// //private static boolean isMainFormFirstLoad;
		// #endregion
		//
		// #region Property
		//
		// #endregion
		//
		// #region Construct
		//
		// #endregion
		//
		// #region Function_Public
		//
		// /// <summary>
		// /// 将指定Double转换为字符串（微软的浮点数格式化会有很大误差）
		// /// </summary>
		// /// <param name="value"></param>
		// /// <param name="decimaldigits">指定保留的小数位数</param>
		// /// <returns></returns>
		// public static String ToString(Double value, int decimaldigits)
		// {
		// String format = "F" + decimaldigits.ToString();
		// String valueString = value.ToString(format);
		// if (!Double.Equals(value, 0))
		// {
		// //取出整数部分
		// int intPlace = (int)Math.Truncate(value);
		// //原值扩大10的decimaldigits次方倍
		// Double valueTemp = Math.Round(value * Math.Pow(10, decimaldigits));
		// //取出原值小数部分扩大10的decimaldigits次方倍
		// Double decimalPlaceTemp = valueTemp - intPlace * Math.Pow(10,
		// decimaldigits);
		// //取出原值小数部分扩大之后的整数部分，即为指定长度的小数文本
		// Int64 decimalPlace = (Int64)Math.Truncate(decimalPlaceTemp);
		// //拼出原值指定精度的字符串
		// if (value < 0)
		// {
		// valueString = String.format("{0}{1}.{2}", CoreResources.String_Minus,
		// intPlace, decimalPlace);
		// }
		// else
		// {
		// valueString = String.format("{0}.{1}", intPlace, decimalPlace);
		// }
		// }
		//
		// return valueString;
		// }
		//
		// public static Double FormString(String valueString)
		// {
		// Double doubleValue = Double.NaN;
		// if (Double.TryParse(valueString, out doubleValue))
		// {
		// String[] splitParts =
		// valueString.Split(CoreResources.String_Dot.ToCharArray());
		// if (splitParts.Length == 2
		// && !String.IsNullOrEmpty(splitParts[0])
		// && !String.IsNullOrEmpty(splitParts[1]))
		// {
		// //判断正负
		// int minusSignIndex = valueString.IndexOf(CoreResources.String_Minus);
		// //小数部分长度
		// int decimalPlaceLength = splitParts[1].Length;
		// //获取整数部分
		// Int64 intPlace = Int64.Parse(splitParts[0]);
		// //扩大整数部分
		// Int64 intPlaceTemp = intPlace * (Int64)Math.Pow(10,
		// decimalPlaceLength);
		// //获得小数部分的整数表示
		// Int64 decimalPlaceTemp = Int64.Parse(splitParts[1]);
		// if (minusSignIndex == 0)
		// {
		// decimalPlaceTemp *= -1;
		// }
		// //扩大的整数部分与小数部分求和
		// Int64 valueTemp = intPlaceTemp + decimalPlaceTemp;
		// //求最终值
		// doubleValue = valueTemp / Math.Pow(10, decimalPlaceLength);
		// }
		// }
		//
		// return doubleValue;
		// }
		//
		// #endregion
		//
		// #region Function_Event
		//
		// #endregion
		//
		// #region Function_Private
		//
		// #endregion
		//
		// #region Event
		//
		// #endregion
		//
		// #region InterfaceMembers
		//
		// #endregion
		//
		// #region NestedTypes
		//
		// #endregion
	}

	public static class EncodeTypeWrap {

		static HashMap<EncodeType, String> encodeTypes = null;

		private static void initialize() {
			if (encodeTypes != null) {
				return;
			}
			encodeTypes = new HashMap<EncodeType, String>(10);

			encodeTypes.put(EncodeType.NONE, CommonProperties.getString("String_EncodeType_None"));
			encodeTypes.put(EncodeType.BYTE, CommonProperties.getString("String_EncodeType_Byte"));
			encodeTypes.put(EncodeType.INT16, CommonProperties.getString("String_EncodeType_Int16"));
			encodeTypes.put(EncodeType.INT24, CommonProperties.getString("String_EncodeType_Int24"));
			encodeTypes.put(EncodeType.INT32, CommonProperties.getString("String_EncodeType_Int32"));
			encodeTypes.put(EncodeType.DCT, CommonProperties.getString("String_EncodeType_DCT"));
			encodeTypes.put(EncodeType.SGL, CommonProperties.getString("String_EncodeType_SGL"));
			encodeTypes.put(EncodeType.LZW, CommonProperties.getString("String_EncodeType_LZW"));
			encodeTypes.put(EncodeType.PNG, CommonProperties.getString("String_EncodeType_PNG"));
			encodeTypes.put(EncodeType.COMPOUND, CommonProperties.getString("String_EncodeType_Compound"));
		}

		/**
		 * 根据编码类型资源字符串获取对应的编码类型
		 * 
		 * @param typeName 编码类型
		 * @return 指定的编码
		 */
		public static EncodeType findType(String typeName) {
			EncodeType result = EncodeType.NONE;
			try {
				initialize();
				Iterator<?> iter = encodeTypes.entrySet().iterator();
				while (iter.hasNext()) {
					java.util.Map.Entry<?, ?> entry = (java.util.Map.Entry<?, ?>) iter.next();
					String value = (String) entry.getValue();
					if (value.equals(typeName)) {
						result = (EncodeType) entry.getKey();
						break;
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return result;
		}

		/**
		 * 根据编码类型获取对应的资源字符串
		 * 
		 * @param type 编码类型
		 * @return 编码名称
		 */
		public static String findName(EncodeType type) {
			String result = "";
			try {
				initialize();
				if (encodeTypes.get(type) == null) {
					result = CommonProperties.getString("String_EncodeType_None");
				} else {
					result = encodeTypes.get(type);
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return result;
		}

		/**
		 * 验证编码类型是否存在于枚举中
		 * 
		 * @param type
		 * @return
		 */
		public static boolean isValidType(EncodeType type) {
			boolean result = true;
			initialize();
			if (encodeTypes.get(type) == null) {
				result = false;
			}
			// return Enum.IsDefined(typeof(EncodeType), type);
			return result;
		}
	}

	public static class EngineTypeWrap {

		// / <summary>
		// /
		// / </summary>
		/**
		 * 根据指定的文件后缀获取相应的文件引擎类型
		 * 
		 * @param fileExt 文件的扩展名
		 * @return 对应的引擎类型
		 */
		public static EngineType getEngineType(String fileExt) {
			EngineType engType = EngineType.UDB;
			EngineInfo[] loadedFileEngines = CommonToolkit.DatasourceWrap.getLoadedFileEngines();

			if (loadedFileEngines != null) {
				for (EngineInfo engInfo : loadedFileEngines) {
					boolean find = false;
					for (String ext : engInfo.getSupportExtensions()) {
						if (fileExt.equalsIgnoreCase(ext)) {
							engType = engInfo.getType();
							find = true;
							break;
						}
					}

					if (find) {
						break;
					}
				}
			}
			return engType;
		}

		// /// <summary>
		// /// 根据引擎类型获得对应的资源信息
		// /// </summary>
		// public static String getEngineTypeName(EngineType engineType)
		// {
		// String engineTypeInfo = String.Empty;
		// try
		// {
		// if (engineType == EngineType.ImagePlugins)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_ImagePlugins;
		// }
		// else if (engineType == EngineType.OraclePlus)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_OraclePlus;
		// }
		// else if (engineType == EngineType.OracleSpatial)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_OracleSpatial;
		// }
		// else if (engineType == EngineType.SQLPlus)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_SQLPlus;
		// }
		// else if (engineType == EngineType.DMPlus)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_DMPlus;
		// }
		// else if (engineType == EngineType.DB2)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_DB2;
		// }
		// else if (engineType == EngineType.Kingbase)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_KingBase;
		// }
		// else if (engineType == EngineType.OGC)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_OGC;
		// }
		// else if (engineType == EngineType.VectorFile)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_VectorFile;
		// }
		// else if (engineType == EngineType.UDB)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_UDB;
		// }
		// else if (engineType == EngineType.PostgreSQL)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_PostgreSQL;
		// }
		// else if (engineType == EngineType.GoogleMaps)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_GoogleMaps;
		// }
		// else if (engineType == EngineType.SuperMapCloud)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_SuperMapCloud;
		// }
		// else if (engineType == EngineType.iServerRest)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_Rest;
		// }
		// else if (engineType == EngineType.MapWorld)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_MapWorld;
		// }
		// else if (engineType == EngineType.BaiduMaps)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_BaiduMaps;
		// }
		// else if (engineType == EngineType.OpenStreetMaps)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_OpenStreetMaps;
		// }
		// else if (engineType == EngineType.PCI)
		// {
		// engineTypeInfo = CoreResources.String_EngineType_PCI;
		// }
		// }
		// catch
		// {
		//
		// }
		// return engineTypeInfo;
		// }
		// #endregion
		//
		// #region Function_Event
		//
		// #endregion
		//
		// #region Function_Private
		//
		// #endregion
		//
		// #region Event
		//
		// #endregion
		//
		// #region InterfaceMembers
		//
		// #endregion
		//
		// #region NestedTypes
		//
		// #endregion
	}

	public static class FieldTypeWrap {

		// #region Variable
		//
		// #endregion
		//
		// #region Property
		//
		// #endregion
		//
		// #region Construct
		//
		// #endregion
		//
		// #region Function_Public
		// /// <summary>
		// /// 根据字段类型获取对应的资源字符串
		// /// </summary>
		// public static String getFieldTypeName(FieldType fieldType)
		// {
		// String type = CoreResources.String_FieldType_Unknown;
		// try
		// {
		// if (fieldType == FieldType.boolean)
		// {
		// type = CoreResources.String_FieldType_boolean;
		// }
		// else if (fieldType == FieldType.DateTime)
		// {
		// type = CoreResources.String_FieldType_Date;
		// }
		// else if (fieldType == FieldType.Double)
		// {
		// type = CoreResources.String_FieldType_Double;
		// }
		// else if (fieldType == FieldType.Byte)
		// {
		// type = CoreResources.String_FieldType_Byte;
		// }
		// else if (fieldType == FieldType.Int16)
		// {
		// type = CoreResources.String_FieldType_Int16;
		// }
		// else if (fieldType == FieldType.int)
		// {
		// type = CoreResources.String_FieldType_int;
		// }
		// else if (fieldType == FieldType.Int64)
		// {
		// type = CoreResources.String_FieldType_Int64;
		// }
		// else if (fieldType == FieldType.LongBinary)
		// {
		// type = CoreResources.String_FieldType_LongBinary;
		// }
		// else if (fieldType == FieldType.Char)
		// {
		// type = CoreResources.String_FieldType_Char;
		// }
		// else if (fieldType == FieldType.Single)
		// {
		// type = CoreResources.String_FieldType_Single;
		// }
		// else if (fieldType == FieldType.Text)
		// {
		// type = CoreResources.String_FieldType_Text;
		// }
		// else if (fieldType == FieldType.WText)
		// {
		// type = CoreResources.String_FieldType_WText;
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return type;
		// }
		//
		// /// <summary>
		// /// 根据字段类型资源字符串获取对应的字段类型
		// /// </summary>
		// public static FieldType getFieldType(String strFieldType)
		// {
		// FieldType type = FieldType.Text;
		// try
		// {
		// if (strFieldType == CoreResources.String_FieldType_boolean)
		// {
		// type = FieldType.boolean;
		// }
		// else if (strFieldType == CoreResources.String_FieldType_Date)
		// {
		// type = FieldType.DateTime;
		// }
		// else if (strFieldType == CoreResources.String_FieldType_Double)
		// {
		// type = FieldType.Double;
		// }
		// else if (strFieldType == CoreResources.String_FieldType_Byte)
		// {
		// type = FieldType.Byte;
		// }
		// else if (strFieldType == CoreResources.String_FieldType_Int16)
		// {
		// type = FieldType.Int16;
		// }
		// else if (strFieldType == CoreResources.String_FieldType_int)
		// {
		// type = FieldType.int;
		// }
		// else if (strFieldType == CoreResources.String_FieldType_Int64)
		// {
		// type = FieldType.Int64;
		// }
		// else if (strFieldType == CoreResources.String_FieldType_LongBinary)
		// {
		// type = FieldType.LongBinary;
		// }
		// else if (strFieldType == CoreResources.String_FieldType_Char)
		// {
		// type = FieldType.Char;
		// }
		// else if (strFieldType == CoreResources.String_FieldType_Single)
		// {
		// type = FieldType.Single;
		// }
		// else if (strFieldType == CoreResources.String_FieldType_Text)
		// {
		// type = FieldType.Text;
		// }
		// else if (strFieldType == CoreResources.String_FieldType_WText)
		// {
		// type = FieldType.WText;
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return type;
		// }
		// #endregion
		//
		// #region Function_Event
		//
		// #endregion
		//
		// #region Function_Private
		//
		// #endregion
		//
		// #region Event
		//
		// #endregion
		//
		// #region InterfaceMembers
		//
		// #endregion
		//
		// #region NestedTypes
		//
		// #endregion
	}

	public static class FilePathConverterWrap {

		// public static String getFileName(String filePath)
		// {
		// return Path.getFileName(filePath);
		// }
		//
		// public static String getRecentFilePath(String filePath)
		// {
		// String result = filePath.Replace("/", " > ");
		// result = result.Replace("\\", " > ");
		// return result;
		// }
	}

	public static class FillMode3DWrap {

		// #region Variable
		//
		// #endregion
		//
		// #region Property
		// static Dictionary<FillMode3D, String> sceneFillMode3Ds = null;
		// /// <summary>
		// /// 三维面填充方式与引用资源字典
		// /// </summary>
		// private static Dictionary<FillMode3D, String> SceneFillMode3Ds
		// {
		// get
		// {
		// if (sceneFillMode3Ds == null)
		// {
		// sceneFillMode3Ds = new Dictionary<FillMode3D, String>();
		// sceneFillMode3Ds.Add(FillMode3D.Fill,
		// CoreResources.String_FillMode3D_Fill);
		// sceneFillMode3Ds.Add(FillMode3D.Line,
		// CoreResources.String_FillMode3D_Line);
		// sceneFillMode3Ds.Add(FillMode3D.LineAndFill,
		// CoreResources.String_FillMode3D_LineAndFill);
		// }
		// return sceneFillMode3Ds;
		// }
		// }
		// #endregion
		//
		// #region Construct
		//
		// #endregion
		//
		// #region Function_Public
		// /// <summary>
		// /// 根据资源字符串获取对应的三维面填充方式
		// /// </summary>
		// /// <param name="name"></param>
		// /// <returns></returns>
		// public static FillMode3D getFillMode3D(String name)
		// {
		// FillMode3D result = FillMode3D.LineAndFill;
		//
		// try
		// {
		// foreach (KeyValuePair<FillMode3D, String> kvp in SceneFillMode3Ds)
		// {
		// if (kvp.Value.Equals(name))
		// {
		// result = kvp.Key;
		// break;
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return result;
		// }
		//
		// /// <summary>
		// /// 根据三维面填充方式获取对应的资源字符串
		// /// </summary>
		// /// <param name="fillMode3D"></param>
		// /// <returns></returns>
		// public static String getFillMode3DName(FillMode3D fillMode3D) {
		// String strName = CoreResources.String_Unknown; // "Unknown";
		// try {
		// strName = SceneFillMode3Ds[fillMode3D];
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return strName;
		// }
		// #endregion
		//
		// #region Function_Event
		//
		// #endregion
		//
		// #region Function_Private
		//
		// #endregion
		//
		// #region Event
		//
		// #endregion
		//
		// #region InterfaceMembers
		//
		// #endregion
		//
		// #region NestedTypes
		//
		// #endregion
	}

	public static class FontWrap {

		// #region Variable
		//
		// #endregion
		//
		// #region Property
		//
		// #endregion
		//
		// #region Construct
		//
		// #endregion
		//
		// #region Function_Public
		// /// <summary>
		// /// 字号大小转化为字体对象实际保存的字高。
		// /// </summary>
		// public static Double FontSizeToMapHeight(Double fontSize, Object
		// mapObject, boolean isSizeFixed)
		// {
		// Double mapHeight = 0;
		// try
		// {
		// mapHeight = fontSize / 2.83;
		// if (isSizeFixed)
		// {
		// mapHeight = fontSize / 2.83;
		// }
		// else
		// {
		// Double fontHeight = fontSize / 2.83;
		// Point2D logicalPntEnd = new Point2D(fontHeight, fontHeight);
		// Point2D logicalPntStart = new Point2D(0, 0);
		// Point2D pointEnd = new Point2D();
		// Point2D pointStart = new Point2D();
		// Map map = mapObject as Map;
		// if (map != null)
		// {
		// pointEnd = map.LogicalToMap(logicalPntEnd);
		// pointStart = map.LogicalToMap(logicalPntStart);
		// mapHeight = Math.Abs(pointEnd.Y - pointStart.Y);
		// }
		// MapLayout mapLayout = mapObject as MapLayout;
		// if (mapLayout != null)
		// {
		// pointEnd = mapLayout.LogicalToLayout(logicalPntEnd);
		// pointStart = mapLayout.LogicalToLayout(logicalPntStart);
		// mapHeight = Math.Abs(pointEnd.Y - pointStart.Y);
		// }
		// }
		// }
		// catch
		// {
		//
		// }
		// return mapHeight;
		// }
		//
		// /// <summary>
		// /// 字体对象实际保存的字高转化为字号大小。
		// /// </summary>
		// public static Double MapHeightToFontSize(Double mapHeight, Object
		// mapObject, boolean isSizeFixed)
		// {
		// Double fontSize = 0;
		// try
		// {
		// fontSize = mapHeight * 2.83;
		// if (isSizeFixed)
		// {
		// fontSize = mapHeight * 2.83;
		// }
		// else
		// {
		// Double fontHeight = mapHeight * 2.83;
		// Point2D pointEnd = new Point2D(fontHeight, fontHeight);
		// Point2D pointStart = new Point2D(0, 0);
		// Point2D logicalPntEnd = new Point2D();
		// Point2D logicalPntStart = new Point2D();
		// Map map = mapObject as Map;
		// if (map != null)
		// {
		// logicalPntEnd = map.MapToLogical(pointEnd);
		// logicalPntStart = map.MapToLogical(pointStart);
		// fontSize = Math.Abs(logicalPntEnd.Y - logicalPntStart.Y);
		// }
		// MapLayout mapLayout = mapObject as MapLayout;
		// if (mapLayout != null)
		// {
		// logicalPntEnd = mapLayout.LayoutToLogical(pointEnd);
		// logicalPntStart = mapLayout.LayoutToLogical(pointStart);
		// fontSize = Math.Abs(logicalPntEnd.Y - logicalPntStart.Y);
		// }
		// }
		// }
		// catch
		// {
		//
		// }
		// return fontSize;
		// }
		//
		// /// <summary>
		// /// 字体对象实际保存的字宽（还需要乘以10作为mapWidth）转化为显示的字宽
		// /// </summary>
		// public static Double MapWidthToFontWidth(Double mapWidth, Object
		// mapObject, boolean isSizeFixed)
		// {
		// Double fontWidth = 0;
		// try
		// {
		// fontWidth = mapWidth;
		// if (!isSizeFixed)
		// {
		// Point2D pointEnd = new Point2D(mapWidth, mapWidth);
		// Point2D pointStart = new Point2D(0, 0);
		// Point2D logicalPntEnd = new Point2D();
		// Point2D logicalPntStart = new Point2D();
		// Map map = mapObject as Map;
		// if (map != null)
		// {
		// logicalPntEnd = map.MapToLogical(pointEnd);
		// logicalPntStart = map.MapToLogical(pointStart);
		// fontWidth = Math.Abs(logicalPntEnd.X - logicalPntStart.X);
		// }
		// MapLayout mapLayout = mapObject as MapLayout;
		// if (mapLayout != null)
		// {
		// logicalPntEnd = mapLayout.LayoutToLogical(pointEnd);
		// logicalPntStart = mapLayout.LayoutToLogical(pointStart);
		// fontWidth = Math.Abs(logicalPntEnd.X - logicalPntStart.X);
		// }
		// }
		// }
		// catch
		// {
		//
		// }
		// return fontWidth;
		// }
		//
		// /// <summary>
		// /// 显示的字宽转化为字体对象实际保存的字宽（还需要除以10）
		// /// </summary>
		// public static Double FontWidthToMapWidth(Double fontWidth, Object
		// mapObject, boolean isSizeFixed)
		// {
		// Double mapWidth = 0;
		// try
		// {
		// mapWidth = fontWidth;
		// if (!isSizeFixed)
		// {
		// Point2D logicalPntEnd = new Point2D(fontWidth, fontWidth);
		// Point2D logicalPntStart = new Point2D(0, 0);
		// Point2D pointEnd = new Point2D();
		// Point2D pointStart = new Point2D();
		//
		// Map map = mapObject as Map;
		// if (map != null)
		// {
		// pointEnd = map.LogicalToMap(logicalPntEnd);
		// pointStart = map.LogicalToMap(logicalPntStart);
		// mapWidth = Math.Abs(pointEnd.X - pointStart.X);
		// }
		// MapLayout mapLayout = mapObject as MapLayout;
		// if (mapLayout != null)
		// {
		// pointEnd = mapLayout.LogicalToLayout(logicalPntEnd);
		// pointStart = mapLayout.LogicalToLayout(logicalPntStart);
		// mapWidth = Math.Abs(pointEnd.X - pointStart.X);
		// }
		// }
		// }
		// catch
		// {
		//
		// }
		// return mapWidth;
		// }
		//
		// #endregion
		//
		// #region Function_Event
		//
		// #endregion
		//
		// #region Function_Private
		//
		// #endregion
		//
		// #region Event
		//
		// #endregion
		//
		// #region InterfaceMembers
		//
		// #endregion
		//
		// #region NestedTypes
		//
		// #endregion
	}

	public static class FormWrap {

		// private static SymbolDialog symbolDialog;
		private static transient CopyOnWriteArrayList<NewWindowListener> newWindowListeners = new CopyOnWriteArrayList<NewWindowListener>();

		public static synchronized void addNewWindowListener(NewWindowListener listener) {
			if (newWindowListeners == null) {
				newWindowListeners = new CopyOnWriteArrayList<NewWindowListener>();
			}

			if (!newWindowListeners.contains(listener)) {
				newWindowListeners.add(listener);
			}
		}

		public static void removeNewWindowListener(NewWindowListener listener) {
			if (newWindowListeners != null && newWindowListeners.contains(listener)) {
				newWindowListeners.remove(listener);
			}
		}

		/**
		 * 发送创建子窗体的事件
		 * 
		 * @param windowType 子窗口类型
		 * @return
		 */
		public static IForm fireNewWindowEvent(WindowType windowType) {
			return fireNewWindowEvent(windowType, "");
		}

		/**
		 * 发送创建子窗体的事件
		 * 
		 * @param windowType 子窗口类型
		 * @param name 指定的窗口名称，如果是地图、场景或者布局子窗体，则默认打开指定名称的地图、布局或者场景。
		 * @return
		 */
		public static IForm fireNewWindowEvent(WindowType windowType, String name) {
			IForm childForm = null;
			try {
				NewWindowEvent event = new NewWindowEvent(Application.getActiveApplication().getMainFrame(), windowType);
				event.setNewWindowName(name);
				fireNewWindowEvent(event);
				childForm = event.getNewWindow();
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return childForm;
		}

		private static void fireNewWindowEvent(NewWindowEvent event) {
			if (newWindowListeners != null) {
				CopyOnWriteArrayList<NewWindowListener> listeners = newWindowListeners;
				Iterator<NewWindowListener> iter = listeners.iterator();
				while (iter.hasNext()) {
					NewWindowListener listener = iter.next();
					listener.newWindow(event);
				}
			}
		}

		public static WindowType getWindowType(IForm form) {
			WindowType type = WindowType.MAP;
			try {
				if (form instanceof IFormLayout) {
					type = WindowType.LAYOUT;
				} else if (form instanceof IFormScene) {
					type = WindowType.SCENE;
				} else if (form instanceof IFormTabular) {
					type = WindowType.TABULAR;
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}

			return type;
		}

		public static IForm getForm(String title, WindowType WindowType) {
			IForm form = null;
			try {
				for (int i = 0; i < Application.getActiveApplication().getMainFrame().getFormManager().getCount(); i++) {
					form = Application.getActiveApplication().getMainFrame().getFormManager().get(i);
					if (title.equalsIgnoreCase(form.getText()) && WindowType == getWindowType(form)) {
						break;
					} else {
						form = null;
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}

			return form;
		}

		// /// <summary>
		// /// 触发创建新窗口事件
		// /// </summary>
		// /// <param name="NewWindowEventArgs">创建新窗口参数类</param>
		// /// <returns></returns>
		// public static JFrame SendNewWindowEvent(NewWindowEventArgs args)
		// {
		// JFrame jFrame = null;
		// try
		// {
		// if (NewWindowEvent != null && args != null)
		// {
		// NewWindowEvent(null, args);
		// jFrame = args.NewForm;
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return jFrame;
		// }
		//
		// /// <summary>
		// /// 将所有的打开的窗口置为需要保存状态
		// /// </summary>
		// public static void SetWindowsNeedSaveState(boolean bNeedSave)
		// {
		// try
		// {
		// for (int i = 0; i <
		// Application.getActiveApplication().getMainFrame().getFormManager().Count;
		// i++)
		// {
		// IForm form =
		// Application.getActiveApplication().getMainFrame().getFormManager().get(i)
		// as IForm;
		// form.NeedSave = bNeedSave;
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// }
		//
		// / <summary>
		// /
		// / </summary>
		/**
		 * 保存所有打开的窗口内容
		 * 
		 * @return 保存成功返回 true，否则返回 false
		 */
		public static boolean saveAllOpenedWindows() {
			boolean result = false;
			try {
				result = Application.getActiveApplication().getMainFrame().getFormManager().saveAll(GlobalParameters.isShowFormClosingInfo());
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}

			return result;
		}

		// /// <summary>
		// /// 根据参数初始化符号对话框。
		// /// </summary>
		// public static SymbolDialog InitSymbolDialog(Resources resource,
		// SymbolType symbolType, Object style, boolean useApplyButton)
		// {
		// SymbolDialog result = null;
		// try
		// {
		// //var timer = new System.Diagnostics.Stopwatch();
		// //timer.Start();
		// if (symbolDialog == null)
		// {
		// symbolDialog = new SymbolDialog();
		// Application.getActiveApplication().getWorkspace().Closed += new
		// WorkspaceClosedEventHandler(Workspace_Closed);
		// }
		// symbolDialog.UseApplyButton = useApplyButton;
		// symbolDialog.Resources = resource;
		// symbolDialog.getType() = symbolType;
		// Symbol symbol = null;
		// if (style is GeoStyle)
		// {
		// symbolDialog.Style = (style as GeoStyle);
		// switch (symbolType)
		// {
		// case SymbolType.Fill:
		// case SymbolType.Fill3D:
		// symbol = resource.FillLibrary.FindSymbol((style as
		// GeoStyle).FillSymbolID);
		// break;
		// case SymbolType.Line:
		// case SymbolType.Line3D:
		// symbol = resource.LineLibrary.FindSymbol((style as
		// GeoStyle).LineSymbolID);
		// break;
		// case SymbolType.Marker:
		// case SymbolType.Marker3D:
		// symbol = resource.MarkerLibrary.FindSymbol((style as
		// GeoStyle).MarkerSymbolID);
		// break;
		// default:
		// break;
		// }
		// }
		// else if (style is GeoStyle3D)
		// {
		// symbolDialog.Style3D = (style as GeoStyle3D);
		// switch (symbolType)
		// {
		// case SymbolType.Fill:
		// case SymbolType.Fill3D:
		// symbol = resource.FillLibrary.FindSymbol((style as
		// GeoStyle3D).FillSymbolID);
		// break;
		// case SymbolType.Line:
		// case SymbolType.Line3D:
		// symbol = resource.LineLibrary.FindSymbol((style as
		// GeoStyle3D).LineSymbolID);
		// break;
		// case SymbolType.Marker:
		// case SymbolType.Marker3D:
		// symbol = resource.MarkerLibrary.FindSymbol((style as
		// GeoStyle3D).MarkerSymbolID);
		// break;
		// default:
		// break;
		// }
		// }
		// else
		// {
		// symbolDialog.Style = new GeoStyle();
		// }
		// if (symbol != null)
		// {
		// symbolDialog.getType() = symbol.getType();
		// }
		// else
		// {
		// symbolDialog.getType() = symbolType;
		// }
		// result = symbolDialog;
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return result;
		// }
		//
		// static void Workspace_Closed(object sender, WorkspaceClosedEventArgs
		// args)
		// {
		// try
		// {
		// args.Workspace.Closed -= new
		// WorkspaceClosedEventHandler(Workspace_Closed);
		// if (symbolDialog != null)
		// {
		// symbolDialog.Dispose();
		// symbolDialog = null;
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// }
		// }

		// public static event NewWindowEventHandler NewWindowEvent;
		// public delegate void NewWindowEventHandler(Object sender,
		// NewWindowEventArgs e);
		// public class NewWindowEventArgs : EventArgs
		// {
		// public NewWindowEventArgs(NewWindowType newWindowType, Form form)
		// {
		// newWindowType = newWindowType;
		// newForm = form;
		// }
		//
		// private Form newForm;
		// public Form NewForm
		// {
		// get
		// {
		// return newForm;
		// }
		// set
		// {
		// newForm = value;
		// }
		// }
		//
		// private NewWindowType newWindowType;
		// public NewWindowType NewWindowType
		// {
		// get
		// {
		// return newWindowType;
		// }
		// }
		//
		// private Object param;
		// public Object Param
		// {
		// get
		// {
		// return param;
		// }
		// set
		// {
		// param = value;
		// }
		// }
		// }
	}

	public static class GeometryTypeWrap {

		// /// <summary>
		// /// 根据几何对象类型资源字符串获取对应的几何对象类型
		// /// </summary>
		// public static String getGeometryTypeName(GeometryType type)
		// {
		// String typeName = String.Empty;
		// try
		// {
		// if (type == GeometryType.GeoArc)
		// {
		// typeName = CoreResources.String_GeometryType_GeoArc;
		// }
		// else if (type == GeometryType.GeoBox)
		// {
		// typeName = CoreResources.String_GeometryType_GeoBox;
		// }
		// else if (type == GeometryType.GeoBSpline)
		// {
		// typeName = CoreResources.String_GeometryType_GeoBSpline;
		// }
		// else if (type == GeometryType.GeoCardinal)
		// {
		// typeName = CoreResources.String_GeometryType_GeoCardinal;
		// }
		// else if (type == GeometryType.GeoChord)
		// {
		// typeName = CoreResources.String_GeometryType_GeoChord;
		// }
		// else if (type == GeometryType.GeoCircle)
		// {
		// typeName = CoreResources.String_GeometryType_GeoCircle;
		// }
		// else if (type == GeometryType.GeoCircle3D)
		// {
		// typeName = CoreResources.String_GeometryType_GeoCircle3D;
		// }
		// else if (type == GeometryType.GeoCompound)
		// {
		// typeName = CoreResources.String_GeometryType_GeoCompound;
		// }
		// else if (type == GeometryType.GeoCone)
		// {
		// typeName = CoreResources.String_GeometryType_GeoCone;
		// }
		// else if (type == GeometryType.GeoCurve)
		// {
		// typeName = CoreResources.String_GeometryType_GeoCurve;
		// }
		// else if (type == GeometryType.GeoCylinder)
		// {
		// typeName = CoreResources.String_GeometryType_GeoCylinder;
		// }
		// else if (type == GeometryType.GeoEllipse)
		// {
		// typeName = CoreResources.String_GeometryType_GeoEllipse;
		// }
		// else if (type == GeometryType.GeoEllipsoid)
		// {
		// typeName = CoreResources.String_GeometryType_GeoEllipsoid;
		// }
		// else if (type == GeometryType.GeoEllipticArc)
		// {
		// typeName = CoreResources.String_GeometryType_GeoEllipticArc;
		// }
		// else if (type == GeometryType.GeoHemiSphere)
		// {
		// typeName = CoreResources.String_GeometryType_GeoHemiSphere;
		// }
		// else if (type == GeometryType.GeoLine)
		// {
		// typeName = CoreResources.String_GeometryType_GeoLine;
		// }
		// else if (type == GeometryType.GeoLine3D)
		// {
		// typeName = CoreResources.String_GeometryType_GeoLine3D;
		// }
		// else if (type == GeometryType.GeoLineM)
		// {
		// typeName = CoreResources.String_GeometryType_GeoLineM;
		// }
		// else if (type == GeometryType.GeoMap)
		// {
		// typeName = CoreResources.String_GeometryType_GeoMap;
		// }
		// else if (type == GeometryType.GeoMapBorder)
		// {
		// typeName = CoreResources.String_GeometryType_GeoMapBorder;
		// }
		// else if (type == GeometryType.GeoMapScale)
		// {
		// typeName = CoreResources.String_GeometryType_GeoMapScale;
		// }
		// else if (type == GeometryType.GeoModel)
		// {
		// typeName = CoreResources.String_GeometryType_GeoModel;
		// }
		// else if (type == GeometryType.GeoNorthArrow)
		// {
		// typeName = CoreResources.String_GeometryType_GeoNorthArrow;
		// }
		// else if (type == GeometryType.GeoPicture)
		// {
		// typeName = CoreResources.String_GeometryType_GeoPicture;
		// }
		// else if (type == GeometryType.GeoPicture3D)
		// {
		// typeName = CoreResources.String_GeometryType_GeoPicture3D;
		// }
		// else if (type == GeometryType.GeoPie)
		// {
		// typeName = CoreResources.String_GeometryType_GeoPie;
		// }
		// else if (type == GeometryType.GeoPie3D)
		// {
		// typeName = CoreResources.String_GeometryType_GeoPie3D;
		// }
		// else if (type == GeometryType.GeoPieCylinder)
		// {
		// typeName = CoreResources.String_GeometryType_GeoPieCylinder;
		// }
		// else if (type == GeometryType.GeoPlacemark)
		// {
		// typeName = CoreResources.String_GeometryType_GeoPlacemark;
		// }
		// else if (type == GeometryType.GeoPoint)
		// {
		// typeName = CoreResources.String_GeometryType_GeoPoint;
		// }
		// else if (type == GeometryType.GeoPoint3D)
		// {
		// typeName = CoreResources.String_GeometryType_GeoPoint3D;
		// }
		// else if (type == GeometryType.GeoPyramid)
		// {
		// typeName = CoreResources.String_GeometryType_GeoPyramid;
		// }
		// else if (type == GeometryType.GeoRectangle)
		// {
		// typeName = CoreResources.String_GeometryType_GeoRectangle;
		// }
		// else if (type == GeometryType.GeoRegion)
		// {
		// typeName = CoreResources.String_GeometryType_GeoRegion;
		// }
		// else if (type == GeometryType.GeoRegion3D)
		// {
		// typeName = CoreResources.String_GeometryType_GeoRegion3D;
		// }
		// else if (type == GeometryType.GeoRoundRectangle)
		// {
		// typeName = CoreResources.String_GeometryType_GeoRoundRectangle;
		// }
		// else if (type == GeometryType.GeoSphere)
		// {
		// typeName = CoreResources.String_GeometryType_GeoSphere;
		// }
		// else if (type == GeometryType.GeoText)
		// {
		// typeName = CoreResources.String_GeometryType_GeoText;
		// }
		// else if (type == GeometryType.GeoText3D)
		// {
		// typeName = CoreResources.String_GeometryType_GeoText3D;
		// }
		// else if (type == GeometryType.GeoParametricLineCompound)
		// {
		// typeName =
		// CoreResources.String_GeometryType_GeoParametricLineCompound;
		// }
		// else if (type == GeometryType.GeoParametricRegionCompound)
		// {
		// typeName =
		// CoreResources.String_GeometryType_GeoParametricRegionCompound;
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return typeName;
		// }
	}

	public static class GeometryWrap {

		// /// <summary>
		// /// 释放对象
		// /// </summary>
		// /// <param name="geometry">被释放的对象</param>
		// public static void ReleaseGeometry(ref Geometry geometry)
		// {
		// try
		// {
		// if (geometry != null)
		// {
		// geometry.Dispose();
		// geometry = null;
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// }
		//
		// public static void ReleaseGeometry(ref GeoPoint geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoLine geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoRegion geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoText geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoRectangle geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoRoundRectangle geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoCircle geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoEllipse geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoPie geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoChord geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoArc geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoEllipticArc geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoCardinal geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoCurve geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoBSpline geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoLineM geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoPoint3D geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoLine3D geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoRegion3D geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoText3D geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoPlacemark geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoCompound geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoPicture geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoModel geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoPicture3D geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoSphere geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoHemiSphere geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoBox geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoCylinder geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoCone geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoPyramid geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoPie3D geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoCircle3D geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoPieCylinder geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoEllipsoid geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoParticle geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoMap geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoMapScale geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoNorthArrow geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoMapBorder geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static void ReleaseGeometry(ref GeoLegend geometry)
		// {
		// Geometry geoBase = geometry as Geometry;
		// ReleaseGeometry(ref geoBase);
		// geometry = null;
		// }
		//
		// public static class GeometryWrap
		// {
		// public static GeoRegion ConvertToRegion(Geometry geometry, int
		// segmentCount)
		// {
		// if (geometry != null)
		// {
		// return geometry.ToRegion(segmentCount);
		// }
		// return null;
		// }
		// }
	}

	public static class GeoStyleWrap {

		static Random random;// 用于保存产生随机的线风格颜色的Random对象
		static Color[] fillColors;
		static int fillNum;

		/**
		 * 对象风格的候选填充颜色集合
		 * 
		 * @return
		 */
		private static Color[] getFillColors() {
			if (fillColors == null) {
				fillColors = new Color[10];
				fillColors[0] = new Color(224, 207, 226);
				fillColors[1] = new Color(151, 191, 242);
				fillColors[2] = new Color(242, 242, 186);
				fillColors[3] = new Color(190, 255, 232);
				fillColors[4] = new Color(255, 190, 232);
				fillColors[5] = new Color(255, 190, 190);
				fillColors[6] = new Color(255, 235, 175);
				fillColors[7] = new Color(233, 255, 190);
				fillColors[8] = new Color(234, 225, 168);
				fillColors[9] = new Color(174, 241, 176);
			}
			return fillColors;
		}

		/**
		 * 不同于上次选用的填充颜色的颜色
		 * 
		 * @return
		 */
		public static Color getFillColor() {

			Color result = Color.PINK;
			if (fillNum >= fillColors.length) {
				fillNum = 0;
			}
			result = fillColors[fillNum];
			fillNum++;
			return result;

		}

		/**
		 * 获取随机的用于线风格的颜色
		 * 
		 * @return
		 */
		public static Color getLineColor() {

			return getRandomLineColor();
		}

		/**
		 * 产生随机的用于线风格的颜色 经过初步试验，新产生的线颜色，饱和度【0-240】最好在30-100之间
		 * 亮度【0-240】最好在75-120之间
		 * 
		 * @return
		 */
		private static Color getRandomLineColor() {
			Color result = Color.PINK;
			try {
				if (random == null) {
					random = new Random();
				}
				result = Color.getHSBColor((float) random.nextInt(360), (float) (random.nextInt(100) / 240.0), (float) (random.nextInt(120) / 240.0));
				// Color color = new Color(random.nextInt(0, 360),
				// random.nextInt(30, 100) / 240.0, random.nextInt(75, 120) /
				// 240.0);
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return result;
		}
	}

	public static class KeyboardWrap {

		// #region Variable
		// /// <summary>
		// /// （钩子监控到键盘操作时发出的）HookKeyboard事件对应的委托
		// /// </summary>
		// public delegate IntPtr HookKeyboardEventHandler(int code, KeyMessage
		// message, KBDLLHOOKSTRUCT param);
		//
		// /// <summary>
		// /// 设置Window钩子的回调函数委托
		// /// </summary>
		// private delegate IntPtr HookKeyboardDelegate(int code, IntPtr wParam,
		// IntPtr lParam);
		// private static HookKeyboardDelegate hookKeyboardProc;
		// private static IntPtr hookKeyboardHandle;
		//
		// private static Keys[] keys;
		// #endregion
		//
		// #region Property
		// /// <summary>
		// /// Keys枚举所有成员的集合
		// /// </summary>
		// public static Keys[] AllKeys
		// {
		// get
		// {
		// if (keys == null)
		// {
		// List<Keys> keys = new List<Keys>();
		// foreach (int i in Enum.getValues(typeof(Keys)))
		// {
		// keys.Add((Keys)i);
		// }
		// keys = keys.ToArray();
		// }
		// return keys;
		// }
		// }
		// #endregion
		//
		// #region Construct
		//
		// #endregion
		//
		// #region Function_Public
		// [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention =
		// CallingConvention.StdCall)]
		// private static extern IntPtr SetWindowsHookEx(int idHook,
		// HookKeyboardDelegate lpfn, IntPtr hMod, int dwThreadId);
		//
		// [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention =
		// CallingConvention.StdCall)]
		// private static extern boolean UnhookWindowsHookEx(IntPtr hhk);
		//
		// [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention =
		// CallingConvention.StdCall)]
		// private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode,
		// IntPtr wParam, IntPtr lParam);
		//
		// /// <summary>
		// /// 注册键盘监控
		// /// </summary>
		// public static void HookWindowsHookEx()
		// {
		// hookKeyboardProc = new HookKeyboardDelegate(HookKeyboardProc);
		// IntPtr handle = Process.getCurrentProcess().MainModule.BaseAddress;
		// hookKeyboardHandle = SetWindowsHookEx((int)HookType.WH_KEYBOARD_LL,
		// hookKeyboardProc, handle, 0);
		// }
		//
		// /// <summary>
		// /// 反注册键盘监控
		// /// </summary>
		// public static void UnhookWindowsHookEx()
		// {
		// UnhookWindowsHookEx(hookKeyboardHandle);
		// }
		//
		// #endregion
		//
		// #region Function_Event
		//
		// #endregion
		//
		// #region Function_Private
		// /// <summary>
		// /// 根据Keys枚举成员的字符串表示，转换得到Keys枚举
		// /// </summary>
		// /// <param name="name"></param>
		// /// <returns></returns>
		// public static Keys getKeysByName(String name)
		// {
		// Keys result = Keys.None;
		// if
		// (name.toLowerCase().Equals(CoreResources.String_ShortCut_Ctrl.toLowerCase()))
		// {
		// result = Keys.Control;
		// }
		// else
		// {
		// foreach (Keys key in AllKeys)
		// {
		// if (key.ToString().Equals(name))
		// {
		// result = key;
		// break;
		// }
		// }
		// }
		// return result;
		// }
		//
		// /// <summary>
		// /// 键盘监控回调函数，里面激活键盘事件
		// /// </summary>
		// /// <param name="code"></param>
		// /// <param name="wParam"></param>
		// /// <param name="lParam"></param>
		// /// <returns></returns>
		// private static IntPtr HookKeyboardProc(int code, IntPtr wParam,
		// IntPtr lParam)
		// {
		// if (HookKeyboard != null && code >= 0)
		// {
		// KBDLLHOOKSTRUCT param =
		// (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam,
		// typeof(KBDLLHOOKSTRUCT));
		// HookKeyboard(code, (KeyMessage)wParam, param);
		// }
		//
		// return CallNextHookEx(hookKeyboardHandle, code, wParam, lParam);
		// }
		// #endregion
		//
		// #region Event
		// /// <summary>
		// /// 钩子监控到键盘操作时触发
		// /// </summary>
		// public static event HookKeyboardEventHandler HookKeyboard;
		// #endregion
		//
		// #region InterfaceMembers
		//
		// #endregion
		//
		// #region NestedTypes
		//
		// #endregion
	}

	public static class LayerWrap {

		public static Rectangle2D getLayerBounds(Map map, Layer layer) {
			Rectangle2D rectangle2D = Rectangle2D.getEMPTY();
			try {
				// 有过滤条件的情况要区分对待 added by zengwh 2012-1-6
				Recordset recordset = null;
				if (layer.getDisplayFilter().getAttributeFilter().equals("")) {
					rectangle2D = layer.getDataset().getBounds();
				} else {
					recordset = ((DatasetVector) layer.getDataset()).query(layer.getDisplayFilter());
					if (recordset != null) {
						rectangle2D = recordset.getBounds();
						recordset.dispose();
					}
				}

				Point2Ds pts = new Point2Ds();
				pts.add(new Point2D(rectangle2D.getLeft(), rectangle2D.getTop()));
				pts.add(new Point2D(rectangle2D.getRight(), rectangle2D.getTop()));
				pts.add(new Point2D(rectangle2D.getRight(), rectangle2D.getBottom()));
				pts.add(new Point2D(rectangle2D.getLeft(), rectangle2D.getBottom()));
				pts.add(new Point2D(rectangle2D.getLeft(), rectangle2D.getTop()));
				GeoRegion region = new GeoRegion(pts);
				try {
					if (map.isDynamicProjection()) {
						CoordSysTranslator.convert(region, layer.getDataset().getPrjCoordSys(), map.getPrjCoordSys(), new CoordSysTransParameter(),
								CoordSysTransMethod.MTH_POSITION_VECTOR);
					}
				} catch (Exception ex) {
					Application.getActiveApplication().getOutput().output(ex);
				}
				rectangle2D = region.getBounds();
				region.dispose();
				// 废弃原来获取显示范围的方法，采用新的方法，使全幅显示图层的效果与地图中只有一个图层时全幅显示地图的效果一样
				// 其中 26 是经验值
				Double dX = rectangle2D.getWidth() / 26;
				Double dY = rectangle2D.getHeight() / 26;
				rectangle2D = new Rectangle2D(rectangle2D.getLeft() - dX, rectangle2D.getBottom() - dY, rectangle2D.getRight() + dX, rectangle2D.getTop() + dY);
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return rectangle2D;
		}

		public static Rectangle2D getLayerBounds(Map map, LayerGroup layerGroup) {
			Rectangle2D rectangle2D = Rectangle2D.getEMPTY();
			try {
				for (int i = 0; i < layerGroup.getCount(); i++) {
					Layer layer = layerGroup.get(i);

					if (layer instanceof LayerGroup) {
						if (i == 0) {
							rectangle2D = getLayerBounds(map, (LayerGroup) layer);
						} else {
							rectangle2D.union(getLayerBounds(map, (LayerGroup) layer));
						}
					} else {
						if (i == 0) {
							rectangle2D = getLayerBounds(map, layer);
						} else {
							rectangle2D.union(getLayerBounds(map, layer));
						}
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return rectangle2D;
		}
		//
		// public static int getLayerIndex(Map map, Layer layer)
		// {
		// int index = -1;
		// try
		// {
		// if (layer.ParentGroup == null)
		// {
		// index = map.Layers.IndexOf(layer);
		// }
		// else
		// {
		// index = layer.ParentGroup.IndexOf(layer);
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return index;
		// }
		//
		// /// <summary>
		// /// 首先判断自己是否可见（图层分组，不包含可见的子图层也视为不可见），然后再判断该图层的父图层是否可见
		// /// </summary>
		// /// <param name="layer"></param>
		// /// <returns></returns>
		// public static boolean IsLayerVisible(Layer layer)
		// {
		// boolean result = false;
		// try
		// {
		// // 先判断自己是否可见
		// if (layer is LayerGroup)
		// {
		// result = IsLayerGroupVisible(layer as LayerGroup);
		// }
		// else
		// {
		// result = layer.IsVisible;
		// }
		//
		// // 然后判断父图层是否都可见
		// LayerGroup parent = layer.ParentGroup;
		// while (result && parent != null)
		// {
		// result = parent.IsVisible;
		// parent = parent.ParentGroup;
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return result;
		// }
		//
		// public static boolean IsLayerGroupVisible(LayerGroup group)
		// {
		// boolean result = false;
		// try
		// {
		// result = group.IsVisible;
		//
		// if (result)
		// {
		// foreach (Layer layer in group)
		// {
		// if (layer is LayerGroup)
		// {
		// result = IsLayerVisible(layer as LayerGroup);
		// }
		// else
		// {
		// result = layer.IsVisible;
		// }
		//
		// if (result)
		// {
		// break;
		// }
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return result;
		// }
		//
		// /// <summary>
		// /// 获取一个图层的连接信息
		// /// </summary>
		// public static JoinItems getJoinItems(Object layer)
		// {
		// JoinItems joinItems = null;
		// try
		// {
		// if (layer is Layer)
		// {
		// Layer layer2D = layer as Layer;
		// if (layer2D != null && layer2D.DisplayFilter != null)
		// {
		// joinItems = layer2D.DisplayFilter.JoinItems;
		// }
		// }
		// else
		// {
		// Layer3DDataset layer3D = layer as Layer3DDataset;
		// if (layer3D != null && layer3D.DisplayFilter != null)
		// {
		// joinItems = layer3D.DisplayFilter.JoinItems;
		// }
		// }
		//
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return joinItems;
		// }
		//
		// //根据指定图层信息（包括外部连接表）、表达式、统计方法进行统计
		// //如果不存在对应的key，那么就是表达式或者字段名（FieldName），那么就直接拿图层的数据集做统计
		// //如果存在对应的key，那么就是 TableName.FieldName 的形式，那么就从字典中取对应的数据集做统计
		// public static Double StatisticValue(Layer layer, String expression,
		// StatisticMode mode)
		// {
		// Double result = 0.0;
		// try
		// {
		// //字典里的字段名都是带表名的全名，而统计接受的字段名参数不能是全名
		// //所以这里过滤一下，如果字典里找不到指定的key，那么就是不带表名的
		// //这种只能是当前数据集
		// DatasetVector statisticDataset = layer.Dataset as DatasetVector;
		// Dictionary<String, DatasetVector> fieldInfosWithDataset =
		// CommonToolkit.RecordsetWrap.getJoinFieldNamesAndDataset(layer);
		// Dictionary<String, FieldInfo> fieldInfos =
		// CommonToolkit.RecordsetWrap.getJoinFieldNamesAndFieldInfo(layer);
		// if (fieldInfosWithDataset.ContainsKey(expression))
		// {
		// statisticDataset = fieldInfosWithDataset[expression];
		// expression = fieldInfos[expression].Name;
		// }
		// result = statisticDataset.Statistic(expression, mode);
		// }
		// catch
		// {
		//
		// }
		//
		// return result;
		// }
		//
		// public static void SetStyleOptions(Layer layer)
		// {
		// try
		// {
		// if (layer != null && layer.Selection != null)
		// {
		// if (layer.Dataset.getType() == DatasetType.Region ||
		// layer.Dataset.getType() == SuperMap.Data.DatasetType.CAD ||
		// layer.Dataset.getType() == SuperMap.Data.DatasetType.Region3D)
		// {
		// layer.Selection.SetStyleOptions(StyleOptions.FillSymbolID, true);
		// layer.Selection.SetStyleOptions(StyleOptions.FillForeColor, true);
		// layer.Selection.SetStyleOptions(StyleOptions.FillBackColor, true);
		// layer.Selection.SetStyleOptions(StyleOptions.FillBackOpaque, true);
		// layer.Selection.SetStyleOptions(StyleOptions.FillGradientMode, true);
		// layer.Selection.SetStyleOptions(StyleOptions.FillGradientOffsetRatioX,
		// true);
		// layer.Selection.SetStyleOptions(StyleOptions.FillGradientOffsetRatioY,
		// true);
		// layer.Selection.SetStyleOptions(StyleOptions.FillGradientAngle,
		// true);
		// layer.Selection.SetStyleOptions(StyleOptions.FillOpaqueRate, true);
		// layer.Selection.SetStyleOptions(StyleOptions.SymbolFill, true);
		// layer.Selection.SetStyleOptions(StyleOptions.LineSymbolID, true);
		// layer.Selection.SetStyleOptions(StyleOptions.LineColor, true);
		// layer.Selection.SetStyleOptions(StyleOptions.LineWidth, true);
		// layer.Selection.SetStyleOptions(StyleOptions.SymbolLine, true);
		// if (layer.Dataset.getType() == SuperMap.Data.DatasetType.CAD)
		// {
		// layer.Selection.SetStyleOptions(StyleOptions.MarkerSymbolID, true);
		// layer.Selection.SetStyleOptions(StyleOptions.MarkerSize, true);
		// layer.Selection.SetStyleOptions(StyleOptions.MarkerAngle, true);
		// layer.Selection.SetStyleOptions(StyleOptions.SymbolMarker, true);
		// }
		// }
		// else if (layer.Dataset.getType() == SuperMap.Data.DatasetType.Line ||
		// layer.Dataset.getType() == SuperMap.Data.DatasetType.LineM ||
		// layer.Dataset.getType() == SuperMap.Data.DatasetType.Network ||
		// layer.Dataset.getType() == SuperMap.Data.DatasetType.Network3D ||
		// layer.Dataset.getType() == SuperMap.Data.DatasetType.Line3D)
		// {
		// layer.Selection.SetStyleOptions(StyleOptions.LineSymbolID, true);
		// layer.Selection.SetStyleOptions(StyleOptions.LineColor, true);
		// layer.Selection.SetStyleOptions(StyleOptions.LineWidth, true);
		// layer.Selection.SetStyleOptions(StyleOptions.SymbolLine, true);
		// }
		// else
		// {
		// layer.Selection.SetStyleOptions(StyleOptions.MarkerSymbolID, true);
		// layer.Selection.SetStyleOptions(StyleOptions.MarkerSize, true);
		// layer.Selection.SetStyleOptions(StyleOptions.MarkerAngle, true);
		// layer.Selection.SetStyleOptions(StyleOptions.SymbolMarker, true);
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// }
		//
		// // 获取有选择集的图层
		// public static Layer[] FindSelectedLayer(IFormMap formMap)
		// {
		// List <Layer> layerResults = new List <Layer>();
		// try
		// {
		// List<Layer> layers =
		// CommonToolkit.MapWrap.getLayers(formMap.MapControl.Map);
		// foreach (Layer layer in layers)
		// {
		// if (layer.Selection != null &&
		// layer.Selection.Count > 0)
		// {
		// layerResults.Add(layer);
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		//
		// return layerResults.ToArray();
		// }
		//
		// // 获取除指定名字外的所有具有选择几何对象图层集合
		// public static Layer[] FindSelectedLayer(IFormMap formMap, String
		// exceptLayerName)
		// {
		// List<Layer> layerResults = new List<Layer>();
		// try
		// {
		// List<Layer> layers =
		// CommonToolkit.MapWrap.getLayers(formMap.MapControl.Map);
		// foreach (Layer layer in layers)
		// {
		// if (layer.Selection != null &&
		// layer.Selection.Count > 0 &&
		// layer.Name != exceptLayerName)
		// {
		// layerResults.Add(layer);
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		//
		// return layerResults.ToArray();
		// }
		//
		// // 获取关联的数据集是除指定数据集外的所有具有选择几何对象图层集合
		// public static Layer[] FindSelectedLayer(IFormMap formMap, Dataset
		// dataset)
		// {
		// List<Layer> layerResults = new List<Layer>();
		// try
		// {
		// List<Layer> layers =
		// CommonToolkit.MapWrap.getLayers(formMap.MapControl.Map);
		// foreach (Layer layer in layers)
		// {
		// if (layer.Dataset != dataset &&
		// layer.Selection != null &&
		// layer.Selection.Count > 0)
		// {
		// layerResults.Add(layer);
		// }
		// }
		// }
		// catch
		// {
		//
		// }
		// return layerResults.ToArray();
		// }
		//
		// // 获取关联的数据源是除指定数据集外的所有具有选择几何对象图层集合
		// public static Layer[] FindSelectedLayer(IFormMap formMap, Datasource
		// datasource)
		// {
		// List<Layer> layerResults = new List<Layer>();
		// try
		// {
		// List<Layer> layers =
		// CommonToolkit.MapWrap.getLayers(formMap.MapControl.Map);
		// foreach (Layer layer in layers)
		// {
		// if (layer.Dataset != null &&
		// layer.Dataset.Datasource != datasource &&
		// layer.Selection != null &&
		// layer.Selection.Count > 0)
		// {
		// layerResults.Add(layer);
		// }
		// }
		// }
		// catch
		// {
		//
		// }
		// return layerResults.ToArray();
		// }
		//
		// public static ImageStretchType getStretchType(String text)
		// {
		// ImageStretchType type = ImageStretchType.None;
		// if (text ==
		// CommonResources.String_LayerProperty_ImageStretchType_None)
		// {
		// type = ImageStretchType.None;
		// }
		// else if (text ==
		// CommonResources.String_LayerProperty_ImageStretchType_StandardDeviation)
		// {
		// type = ImageStretchType.StandardDeviation;
		// }
		// else if (text ==
		// CommonResources.String_LayerProperty_ImageStretchType_MinimumMaximum)
		// {
		// type = ImageStretchType.MinimumMaximum;
		// }
		// else if (text ==
		// CommonResources.String_LayerProperty_ImageStretchType_HistogramEqualization)
		// {
		// type = ImageStretchType.HistogramEqualization;
		// }
		// else if (text ==
		// CommonResources.String_LayerProperty_ImageStretchType_HistogramSpecification)
		// {
		// type = ImageStretchType.HistogramSpecification;
		// }
		// else if (text ==
		// CommonResources.String_LayerProperty_ImageStretchType_Gaussian)
		// {
		// type = ImageStretchType.Gaussian;
		// }
		//
		// return type;
		// }
		//
		// public static String getStretchTypeText(ImageStretchType? type)
		// {
		// String text = String.Empty;
		// switch (type)
		// {
		// case ImageStretchType.None:
		// text = CommonResources.String_LayerProperty_ImageStretchType_None;
		// break;
		// case ImageStretchType.StandardDeviation:
		// text =
		// CommonResources.String_LayerProperty_ImageStretchType_StandardDeviation;
		// break;
		// case ImageStretchType.MinimumMaximum:
		// text =
		// CommonResources.String_LayerProperty_ImageStretchType_MinimumMaximum;
		// break;
		// case ImageStretchType.HistogramEqualization:
		// text =
		// CommonResources.String_LayerProperty_ImageStretchType_HistogramEqualization;
		// break;
		// case ImageStretchType.HistogramSpecification:
		// text =
		// CommonResources.String_LayerProperty_ImageStretchType_HistogramSpecification;
		// break;
		// case ImageStretchType.Gaussian:
		// text =
		// CommonResources.String_LayerProperty_ImageStretchType_Gaussian;
		// break;
		// }
		//
		// return text;
		// }
	}

	public static class LayoutWrap {

		public static boolean checkAvailableLayoutName(String newLayoutName, String oldLayoutName) {
			boolean flag = false;
			newLayoutName = newLayoutName.toLowerCase();
			oldLayoutName = oldLayoutName.toLowerCase();
			if (newLayoutName == null || newLayoutName.length() <= 0) {
				flag = false;
			} else {
				ArrayList<String> allLayoutNames = new ArrayList<String>();
				for (int index = 0; index < Application.getActiveApplication().getWorkspace().getLayouts().getCount(); index++) {
					allLayoutNames.add(Application.getActiveApplication().getWorkspace().getLayouts().get(index).toLowerCase());
				}

				for (int index = 0; index < Application.getActiveApplication().getMainFrame().getFormManager().getCount(); index++) {
					IForm form = Application.getActiveApplication().getMainFrame().getFormManager().get(index);
					if (form instanceof IFormLayout) {
						if (!form.getText().equalsIgnoreCase(oldLayoutName)) {
							allLayoutNames.add(form.getText().toLowerCase());
						}
					}
				}

				if (!allLayoutNames.contains(newLayoutName)) {
					flag = true;
				}
			}
			return flag;
		}

		/**
		 * 获取具有指定前缀的可用布局名称
		 * 
		 * @param layoutName 指定前缀
		 * @param isNewWindow 是否是新窗口
		 * @return
		 */
		public static String getAvailableLayoutName(String layoutName, boolean isNewWindow) {
			String availableLayoutName = layoutName.toLowerCase();

			try {
				if (layoutName == null || layoutName.length() <= 0) {
					layoutName = CoreProperties.getString("String_WorkspaceNodeCaptionLayout");
				}

				ArrayList<String> allLayoutNames = new ArrayList<String>();
				for (int index = 0; index < Application.getActiveApplication().getWorkspace().getLayouts().getCount(); index++) {
					allLayoutNames.add(Application.getActiveApplication().getWorkspace().getLayouts().get(index).toLowerCase());
				}

				for (int index = 0; index < Application.getActiveApplication().getMainFrame().getFormManager().getCount(); index++) {
					IForm form = Application.getActiveApplication().getMainFrame().getFormManager().get(index);
					if (form instanceof IFormLayout) {
						allLayoutNames.add(form.getText().toLowerCase());
					}
				}

				if (!allLayoutNames.contains(availableLayoutName)) {
					availableLayoutName = layoutName;
				} else {
					int indexLayoutName = 1;
					while (true) {
						availableLayoutName = String.format("%s%d", layoutName, indexLayoutName);
						if (!allLayoutNames.contains(availableLayoutName.toLowerCase())) {
							break;
						}

						indexLayoutName += 1;
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}

			return availableLayoutName;
		}

		/**
		 * 批量删除指定名称的布局
		 * 
		 * @param strMapLatoutNames
		 */
		public static void deleteMapLayout(String[] mapLatoutNames) {
			try {
				String message = "";
				if (mapLatoutNames.length == 1) {
					message = CoreProperties.getString("String_LayoutDelete_Confirm");
					message = message + "\r\n" + String.format(CoreProperties.getString("String_LayoutDelete_Confirm_One"), mapLatoutNames[0]);
				} else {
					message = CoreProperties.getString("String_LayoutDelete_Confirm");
					message = message + "\r\n" + String.format(CoreProperties.getString("String_LayoutDelete_Confirm_Multi"), mapLatoutNames.length);
				}
				if (message != "") {
					if (JOptionPane.showConfirmDialog(null, message, CoreProperties.getString("String_LayoutDelete"), JOptionPane.OK_CANCEL_OPTION,
							JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
						for (String mapLayoutName : mapLatoutNames) {
							Application.getActiveApplication().getWorkspace().getLayouts().remove(mapLayoutName);
						}
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
		}

	}

	public static class ListWrap {

		// public static boolean IsListOnlyContain<T>(List<T> list, params T[]
		// checkItems)
		// {
		// boolean result = false;
		// if (list.Count > 0 && checkItems.Length > 0)
		// {
		// result = list.TrueForAll(item =>
		// {
		// boolean equal = false;
		// foreach (T checkItem in checkItems)
		// {
		// if (checkItem.Equals(item))
		// {
		// equal = true;
		// break;
		// }
		// }
		// return equal;
		// });
		// }
		// return result;
		// }
		//
		// public static boolean IsListContainAny<T>(List<T> list, params T[]
		// checkItems)
		// {
		// boolean result = false;
		// if (list.Count > 0 && checkItems.Length > 0)
		// {
		// result = list.Exists(item =>
		// {
		// boolean equal = false;
		// foreach (T checkItem in checkItems)
		// {
		// if (checkItem.Equals(item))
		// {
		// equal = true;
		// break;
		// }
		// }
		// return equal;
		// });
		// }
		// return result;
		// }
	}

	public static class MappingSpecificationWrap {

		// public static String PathFeatureDic =
		// CoreResources.String_AutoMapMaking_DictionaryPathRoot +
		// "FeatureDictionary.xml";
		// public static String PathDisplayDic =
		// CoreResources.String_AutoMapMaking_DictionaryPathRoot +
		// "EmapDisplayStandard.xml";
		// public static String pathspecialSymbolDic =
		// CoreResources.String_AutoMapMaking_DictionaryPathRoot +
		// "SpecialSymbolDictionary.xml";
		// private static XmlDocument featureDictionay;
		// private static XmlDocument emapDisplayStandard;
		// private static XmlDocument specialSymbolDictionay;
		//
		// public static XmlDocument FeatureDictionay
		// {
		// get
		// {
		// if (featureDictionay == null)
		// {
		// featureDictionay = new XmlDocument();
		// featureDictionay.Load(PathFeatureDic);
		// }
		//
		// return featureDictionay;
		// }
		// }
		//
		// public static XmlDocument EmapDisplayStandard
		// {
		// get
		// {
		// if (emapDisplayStandard == null)
		// {
		// emapDisplayStandard = new XmlDocument();
		// emapDisplayStandard.Load(PathDisplayDic);
		// }
		//
		// return emapDisplayStandard;
		// }
		// }
		//
		// public static XmlDocument SpecialSymbolDictionay
		// {
		// get
		// {
		// if (specialSymbolDictionay == null)
		// {
		// specialSymbolDictionay = new XmlDocument();
		// specialSymbolDictionay.Load(pathspecialSymbolDic);
		// }
		// return specialSymbolDictionay;
		// }
		// }
		//
		// public static void ReloadFeatureDictionay()
		// {
		// if (featureDictionay != null)
		// {
		// featureDictionay.Load(PathFeatureDic);
		// }
		// }
		//
		// public static void ReloadEmapDisplayStandard()
		// {
		// if (emapDisplayStandard != null)
		// {
		// emapDisplayStandard.Load(PathDisplayDic);
		// }
		// }
		//
		// public static void ReloadSpecialSymbolDictionay()
		// {
		// if (specialSymbolDictionay != null)
		// {
		// specialSymbolDictionay.Load(pathspecialSymbolDic);
		// }
		// }
	}

	public static class MapWrap {
		public static Layer findLayer(Map map, String name) {
			Layer layer = null;
			try {
				layer = map.getLayers().get(name);
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}

			return layer;
		}

		public static boolean reomveLayer(Map map, String name) {
			boolean result = false;
			try {
				Layer layer = findLayer(map, name);
				if (layer.getParentGroup() == null) {
					result = map.getLayers().remove(name);
				} else {
					layer.getParentGroup().remove(layer);
					result = true;
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}

			return result;
		}

		public static boolean reomveLayer(Map map, Layer layer) {
			boolean result = false;
			try {
				result = map.getLayers().remove(layer);
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}

			return result;
		}

		public static boolean findLayer(Map map, Layer layer) {
			boolean result = false;
			try {
				result = map.getLayers().remove(layer);
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}

			return result;
		}

		/**
		 * 获取地图的所有子图层
		 * 
		 * @param map
		 * @return
		 */
		public static ArrayList<Layer> getLayers(Map map) {
			ArrayList<Layer> layers = new ArrayList<Layer>();
			try {
				for (int i = 0; i < map.getLayers().getCount(); i++) {
					Layer layer = map.getLayers().get(i);
					if (layer instanceof LayerGroup) {
						layers.addAll(getLayers((LayerGroup) layer));
					} else {
						layers.add(layer);
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}

			return layers;
		}

		/**
		 * 获取地图的所有子图层
		 * 
		 * @param map
		 * @param isCoverGroup 是否包含图层分组
		 * @return
		 */
		public static ArrayList<Layer> getLayers(Map map, boolean isCoverGroup) {
			ArrayList<Layer> layers = new ArrayList<Layer>();
			try {
				for (int i = 0; i < map.getLayers().getCount(); i++) {
					Layer layer = map.getLayers().get(i);
					if (layer instanceof LayerGroup) {
						layers.addAll(getLayers((LayerGroup) layer, isCoverGroup));
						if (isCoverGroup) {
							layers.add(layer);
						}
					} else {
						layers.add(layer);
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}

			return layers;
		}

		/**
		 * 获取图层分组的所有子图层
		 * 
		 * @param layerGroup
		 * @return
		 */
		public static ArrayList<Layer> getLayers(LayerGroup layerGroup) {
			ArrayList<Layer> layers = new ArrayList<Layer>();
			try {
				for (int i = 0; i < layerGroup.getCount(); i++) {
					Layer layer = layerGroup.get(i);
					if (layer instanceof LayerGroup) {
						layers.addAll(getLayers((LayerGroup) layer));
					} else {
						layers.add(layer);
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return layers;
		}

		/**
		 * 获取图层分组的所有子图层
		 * 
		 * @param layerGroup
		 * @param isCoverGroup 是否包含图层分组
		 * @return
		 */
		public static ArrayList<Layer> getLayers(LayerGroup layerGroup, boolean isCoverGroup) {
			ArrayList<Layer> layers = new ArrayList<Layer>();
			try {
				for (int i = 0; i < layerGroup.getCount(); i++) {
					Layer layer = layerGroup.get(i);
					if (layer instanceof LayerGroup) {
						layers.addAll(getLayers((LayerGroup) layer, isCoverGroup));
						if (isCoverGroup) {
							layers.add(layer);
						}
					} else {
						layers.add(layer);
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return layers;
		}

		/**
		 * 获取可用的图层的标题
		 * 
		 * @param map 地图
		 * @param parent 所在的分组，如果是根图层，则为null
		 * @param caption 指定的图层标题
		 * @return
		 */
		public static String getAvailableLayerCaption(Map map, LayerGroup parent, String caption) {
			String layerCaption = "";

			try {
				if (parent == null) {
					// layerCaption =
					// map.getLayers().getAvailableCaption(caption);
				} else {
					// layerCaption = parent.getAvailableCaption(caption);
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}

			return layerCaption;
		}

		/**
		 * 添加指定数据集到地图中
		 * 
		 * @param map
		 * @param dataset
		 * @param addToHead
		 * @return
		 */
		public static Layer addDatasetToMap(Map map, Dataset dataset, boolean addToHead) {
			Layer layer = null;
			try {
				if (dataset != null) {
					layer = map.getLayers().add(dataset, addToHead);
					if (layer == null) {
						Application.getActiveApplication().getOutput()
								.output(String.format(CoreProperties.getString("String_DatasetOpenFaild"), dataset.getName()));
					} else {
						if (dataset.getType() == DatasetType.REGION || dataset.getType() == DatasetType.REGION3D
								|| dataset.getType() == DatasetType.PARAMETRICREGION) {
							LayerSettingVector setting = (LayerSettingVector) layer.getAdditionalSetting();
							setting.getStyle().setFillForeColor(GeoStyleWrap.getFillColor());
							setting.getStyle().setLineColor(GeoStyleWrap.getLineColor());
						} else if (dataset.getType() == DatasetType.LINE || dataset.getType() == DatasetType.NETWORK
								|| dataset.getType() == DatasetType.NETWORK3D || dataset.getType() == DatasetType.PARAMETRICLINE
								|| dataset.getType() == DatasetType.LINEM || dataset.getType() == DatasetType.LINE3D) {
							LayerSettingVector setting = (LayerSettingVector) layer.getAdditionalSetting();
							setting.getStyle().setLineColor(GeoStyleWrap.getLineColor());
						} else if (dataset.getType() == DatasetType.POINT || dataset.getType() == DatasetType.POINT3D) {
							LayerSettingVector setting = (LayerSettingVector) layer.getAdditionalSetting();
							setting.getStyle().setLineColor(GeoStyleWrap.getLineColor());
						}
						if (layer.getSelection() != null) {
							layer.getSelection().setDefaultStyleEnabled(true);
						}
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}

			return layer;
		}

		/**
		 * 添加指定数据集到地图中
		 * 
		 * @param map
		 * @param dataset
		 * @param parent
		 * @param addToHead
		 * @return
		 */
		public static Layer AddDatasetToMap(Map map, Dataset dataset, LayerGroup parent, boolean addToHead) {
			Layer layer = null;
			try {
				if (dataset != null) {
					layer = addDatasetToMap(map, dataset, addToHead);

					// 将图层移动到分组中
					if (parent != null) {
						parent.add(layer);
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}

			return layer;
		}

		public static void AddLayer(Map map, LayerGroup parent, Layer layer) {
			try {
				if (parent == null) {
					map.getLayers().add(layer);
				} else {
					parent.add(layer);
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
		}

		public static void deleteMaps(String[] mapNames) {
			try {
				String message = CoreProperties.getString("String_MapDelete_Confirm");
				if (mapNames.length == 1) {
					message = message + "\r\n" + String.format(CoreProperties.getString("String_MapDelete_Confirm_One"), mapNames[0]);
				} else {
					message = message + "\r\n" + String.format(CoreProperties.getString("String_MapDelete_Confirm_Multi"), mapNames.length);
				}

				if (JOptionPane.showConfirmDialog(null, message, CoreProperties.getString("String_MapDelete"), JOptionPane.OK_CANCEL_OPTION,
						JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
					for (String mapName : mapNames) {
						Application.getActiveApplication().getWorkspace().getMaps().remove(mapName);
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
		}

		/**
		 * 判断保存地图时名称是否可用
		 * 
		 * <<<<<<< HEAD
		 * 
		 * @param newMapName 新地图名称
		 * @param oldMapName 原来的地图名称 =======
		 * @param newMapName 新地图名称
<<<<<<< HEAD
		 * @param oldMapName 原来的地图名称 >>>>>>> 533c07acf1421d7eb36d9a2c1cae01b53ec85ebe
=======
		 * @param oldMapName 原来的地图名称 >>>>>>>
		 *            533c07acf1421d7eb36d9a2c1cae01b53ec85ebe
>>>>>>> 4b5f30f8e3eea409ff22c450cc9bdb2fd07af87f
		 * @return
		 */
		public static boolean checkAvailableMapName(String newMapName, String oldMapName) {
			boolean flag = false;
			String newAvailableMapName = newMapName.toLowerCase();
			String oldAvailableMapName = oldMapName.toLowerCase();
			if (newAvailableMapName == null || newAvailableMapName.length() <= 0) {
				flag = false;
			} else {
				ArrayList<String> allMapNames = new ArrayList<String>();
				int mapsCount = Application.getActiveApplication().getWorkspace().getMaps().getCount();
				for (int index = 0; index < mapsCount; index++) {
					allMapNames.add(Application.getActiveApplication().getWorkspace().getMaps().get(index).toLowerCase());
				}
				int formManagerCount = Application.getActiveApplication().getMainFrame().getFormManager().getCount();
				for (int index = 0; index < formManagerCount; index++) {
					IForm form = Application.getActiveApplication().getMainFrame().getFormManager().get(index);
					if (form instanceof IFormMap) {
						if (!form.getText().equalsIgnoreCase(oldAvailableMapName)) {
							allMapNames.add(form.getText().toLowerCase());
						}
					}
				}
				if (!allMapNames.contains(newAvailableMapName)) {
					flag = true;
				}
			}
			return flag;
		}

		/**
		 * 获取具有指定前缀的可用地图名称
		 * 
		 * @param mapName
		 * @param isNewWindow
		 * @return
		 */
		public static String getAvailableMapName(String mapName, boolean isNewWindow) {
			// 1、获取被检查的地图名称
			String availableMapName = mapName.toLowerCase();
			if (mapName == null || mapName.length() <= 0) {
				mapName = CoreProperties.getString("String_WorkspaceNodeCaptionMap");
			}

			ArrayList<String> allMapNames = new ArrayList<String>();
			int mapsCount = Application.getActiveApplication().getWorkspace().getMaps().getCount();
			for (int index = 0; index < mapsCount; index++) {
				allMapNames.add(Application.getActiveApplication().getWorkspace().getMaps().get(index).toLowerCase());
			}
			int formManagerCount = Application.getActiveApplication().getMainFrame().getFormManager().getCount();
			for (int index = 0; index < formManagerCount; index++) {
				IForm form = Application.getActiveApplication().getMainFrame().getFormManager().get(index);
				if (form instanceof IFormMap) {
					// 对于新窗口，不能用地图名字作为窗口标题，地图名和窗口标题可能会不一样，直接使用窗口标题
					if (isNewWindow) {
						allMapNames.add(form.getText().toLowerCase());
					} else if (!form.getText().equalsIgnoreCase("")) {
						allMapNames.add(form.getText().toLowerCase());
					}
				}
			}

			// 3、检查已有的地图名称中是否包含了被检查的地图名称，如果包含则处理一下
			if (!allMapNames.contains(availableMapName)) {
				availableMapName = mapName;
			} else {
				int indexMapName = 1;
				while (true) {
					availableMapName = String.format("%s%d", mapName, indexMapName);
					if (!allMapNames.contains(availableMapName.toLowerCase())) {
						break;
					}

					indexMapName += 1;
				}
			}
			return availableMapName;
		}
	}

	public static class PixelformatWrap {

		// #region Variable
		// static Dictionary<Pixelformat, String> pixelformats = null;
		// #endregion
		//
		// #region Property
		// #endregion
		//
		// #region Construct
		// static PixelformatWrap()
		// {
		// Initialize();
		// }
		// #endregion
		//
		// #region Function_Public
		// /// <summary>
		// /// 获取数据集是否支持指定的像素格式
		// /// </summary>
		// public static boolean IsSupportedPixelformat(DatasetType datasetType,
		// Pixelformat pixelformat)
		// {
		// boolean result = true;
		//
		// if (datasetType == DatasetType.Grid || datasetType ==
		// DatasetType.GridCollection)
		// {
		// if (pixelformat == Pixelformat.RGB || pixelformat ==
		// Pixelformat.RGBA)
		// {
		// result = false;
		// }
		// }
		// return result;
		// }
		//
		// /// <summary>
		// /// 根据数据集类型和像素类型获取对应的资源字符串
		// /// </summary>
		// public static String getPixelformatName(Pixelformat pixelformat)
		// {
		// String strName = CoreResources.String_Unknown;
		// if (pixelformats.ContainsKey(pixelformat))
		// {
		// strName = pixelformats[pixelformat];
		// }
		// return strName;
		// }
		// #endregion
		//
		// #region Function_Event
		//
		// #endregion
		//
		// #region Function_Private
		// private static void Initialize()
		// {
		// pixelformats = new Dictionary<Pixelformat, String>();
		// pixelformats.Add(Pixelformat.UBit1,
		// CommonResources.String_Pixelformat_UBit1);
		// pixelformats.Add(Pixelformat.UBit4,
		// CommonResources.String_Pixelformat_UBit4);
		// pixelformats.Add(Pixelformat.Bit8,
		// CommonResources.String_Pixelformat_Bit8);
		// pixelformats.Add(Pixelformat.UBit8,
		// CommonResources.String_Pixelformat_UBit8);
		// pixelformats.Add(Pixelformat.Bit16,
		// CommonResources.String_Pixelformat_Bit16);
		// pixelformats.Add(Pixelformat.UBit16,
		// CommonResources.String_Pixelformat_UBit16);
		// pixelformats.Add(Pixelformat.RGB,
		// CommonResources.String_Pixelformat_RGB);
		// pixelformats.Add(Pixelformat.RGBA,
		// CommonResources.String_Pixelformat_RGBA);
		// pixelformats.Add(Pixelformat.Bit32,
		// CommonResources.String_Pixelformat_Bit32);
		// pixelformats.Add(Pixelformat.UBit32,
		// CommonResources.String_Pixelformat_UBit32);
		// pixelformats.Add(Pixelformat.Bit64,
		// CommonResources.String_Pixelformat_Bit64);
		// pixelformats.Add(Pixelformat.Single,
		// CommonResources.String_Pixelformat_Single);
		// pixelformats.Add(Pixelformat.Double,
		// CommonResources.String_Pixelformat_Double);
		// }
		//
	}

	public static class RecordsetWrap {

		// /// <summary>
		// /// 获得一个矢量图层对应数据集的记录集，包含连接信息
		// /// </summary>
		// public static Recordset getJoinRecordset(Object layer, boolean
		// onlyFieldInfos)
		// {
		// Recordset recordset = null;
		// try
		// {
		// DatasetVector dataset = null;
		// if (layer is Layer)
		// {
		// dataset = (layer as Layer).Dataset as DatasetVector;
		// }
		// else if (layer is Layer3DDataset)
		// {
		// dataset = (layer as Layer3DDataset).Dataset as DatasetVector;
		// }
		// JoinItems joinItems = CommonToolkit.LayerWrap.getJoinItems(layer);
		// recordset = getJoinRecordset(dataset, onlyFieldInfos, joinItems);
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return recordset;
		// }
		//
		// //public static FieldInfos getJoinFieldInfos(Object layer)
		// //{
		// // FieldInfos fieldInfos = null;
		// // try
		// // {
		// // DatasetVector dataset = null;
		// // if (layer is Layer)
		// // {
		// // dataset = (layer as Layer).Dataset as DatasetVector;
		// // }
		// // else if (layer is Layer3DDataset)
		// // {
		// // dataset = (layer as Layer3DDataset).Dataset as DatasetVector;
		// // }
		// // JoinItems joinItems = CommonToolkit.LayerWrap.getJoinItems(layer);
		// // fieldInfos = getJoinFieldInfos(dataset, joinItems);
		// // }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// // return fieldInfos;
		// //}
		//
		// ///// <summary>
		// ///// 获得一个矢量数据集带指定连接信息的记录集
		// ///// </summary>
		// //public static Recordset getJoinRecordset(DatasetVector dataset,
		// boolean onlyFieldInfos, JoinItems joinItems)
		// //{
		// // Recordset recordset = null;
		// // try
		// // {
		// // QueryParameter queryparameter = new QueryParameter();
		// // queryparameter.CursorType = CursorType.Static;
		// // queryparameter.HasGeometry = false;
		// // queryparameter.JoinItems.AddRange(joinItems.ToArray());
		// // List<DatasetVector> datasetList = new List<DatasetVector>();
		// // datasetList.Add(dataset);
		// // for (int i = 0; i < joinItems.Count; i++)
		// // {
		// // JoinItem joinItem = joinItems.get(i);
		// // String joinDatasetName = joinItem.ForeignTable;
		// // DatasetVector joinDataset =
		// dataset.Datasource.Datasets[joinDatasetName] as DatasetVector;
		// // if (joinDataset != null)
		// // {
		// // datasetList.Add(joinDataset);
		// // }
		// // }
		//
		// // List<String> resultFields = new List<String>();
		// // foreach (DatasetVector data in datasetList)
		// // {
		// // QueryParameter para = new QueryParameter();
		// // para.CursorType = CursorType.Static;
		// // para.HasGeometry = false;
		// // para.AttributeFilter = "1<0";
		// // Recordset cord = null;
		// // try
		// // {
		// // cord = data.Query(para);
		// // FieldInfos fieldInfos = cord.getFieldInfos();
		// // foreach (SuperMap.Data.FieldInfo info in fieldInfos)
		// // {
		// // resultFields.Add(data.TableName + "." + info.Name);
		// // }
		// // cord.Dispose();
		// // cord = null;
		// // }
		// // catch
		// // {
		// // if (cord != null)
		// // {
		// // cord.Dispose();
		// // }
		// // }
		// // }
		// // queryparameter.ResultFields = resultFields.ToArray();
		// // if (onlyFieldInfos)
		// // {
		// // queryparameter.AttributeFilter = "1<0";
		// // }
		// // recordset = dataset.Query(queryparameter);
		// // }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// // return recordset;
		// //}
		//
		// /// <summary>
		// /// 获得一个矢量数据集带指定连接信息的记录集
		// /// </summary>
		// public static Recordset getJoinRecordset(DatasetVector dataset,
		// boolean onlyFieldInfos, JoinItems joinItems)
		// {
		// Recordset recordset = null;
		// try
		// {
		// QueryParameter queryparameter = new QueryParameter();
		// queryparameter.CursorType = CursorType.Static;
		// queryparameter.HasGeometry = false;
		// queryparameter.JoinItems.AddRange(joinItems.ToArray());
		// List<String> resultFields = getJoinFieldNames(dataset, joinItems);
		// queryparameter.ResultFields = resultFields.ToArray();
		// if (onlyFieldInfos)
		// {
		// queryparameter.AttributeFilter = "1<0";
		// }
		// recordset = dataset.Query(queryparameter);
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return recordset;
		// }
		//
		// /// <summary>
		// /// 获得一个矢量数据集带指定连接信息的记录集,同时输出带表名的字段名列表
		// /// </summary>
		// public static Recordset getJoinRecordset(DatasetVector dataset,
		// boolean onlyFieldInfos, JoinItems joinItems, out List<String>
		// resultFields)
		// {
		// Recordset recordset = null;
		// resultFields = null;
		// try
		// {
		// QueryParameter queryparameter = new QueryParameter();
		// queryparameter.CursorType = CursorType.Static;
		// queryparameter.HasGeometry = false;
		// queryparameter.JoinItems.AddRange(joinItems.ToArray());
		// resultFields = getJoinFieldNames(dataset, joinItems);
		// queryparameter.ResultFields = resultFields.ToArray();
		// if (onlyFieldInfos)
		// {
		// queryparameter.AttributeFilter = "1<0";
		// }
		// recordset = dataset.Query(queryparameter);
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return recordset;
		// }
		//
		// /// <summary>
		// /// 获取图层的字段集合，带连接信息
		// /// </summary>
		// /// <param name="layer"></param>
		// /// <returns></returns>
		// public static List<FieldInfo> getJoinFieldInfos(Object layer)
		// {
		// List<FieldInfo> fieldInfos = null;
		// try
		// {
		// DatasetVector dataset = null;
		// if (layer is Layer)
		// {
		// dataset = (layer as Layer).Dataset as DatasetVector;
		// }
		// else if (layer is Layer3DDataset)
		// {
		// dataset = (layer as Layer3DDataset).Dataset as DatasetVector;
		// }
		//
		// JoinItems joinItems = CommonToolkit.LayerWrap.getJoinItems(layer);
		// fieldInfos = getJoinFieldInfos(dataset, joinItems);
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		//
		// return fieldInfos;
		// }
		//
		// /// <summary>
		// /// 获取指定图层的字段名集合，字段带表名
		// /// </summary>
		// /// <param name="layer"></param>
		// /// <returns></returns>
		// public static List<String> getJoinFieldNames(Object layer)
		// {
		// List<String> fields = null;
		// try
		// {
		// DatasetVector dataset = null;
		// if (layer is Layer)
		// {
		// dataset = (layer as Layer).Dataset as DatasetVector;
		// }
		// else if (layer is Layer3DDataset)
		// {
		// dataset = (layer as Layer3DDataset).Dataset as DatasetVector;
		// }
		//
		// JoinItems joinItems = CommonToolkit.LayerWrap.getJoinItems(layer);
		// fields = getJoinFieldNames(dataset, joinItems);
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		//
		// return fields;
		// }
		//
		// /// <summary>
		// /// 获取指定图层的字段名集合，字段不带表名
		// /// </summary>
		// /// <param name="layer"></param>
		// /// <returns></returns>
		// public static List<String> getJoinFieldNamesWithoutDatasetName(Object
		// layer)
		// {
		// List<String> fields = null;
		// try
		// {
		// DatasetVector dataset = null;
		// if (layer is Layer)
		// {
		// dataset = (layer as Layer).Dataset as DatasetVector;
		// }
		// else if (layer is Layer3DDataset)
		// {
		// dataset = (layer as Layer3DDataset).Dataset as DatasetVector;
		// }
		//
		// JoinItems joinItems = CommonToolkit.LayerWrap.getJoinItems(layer);
		// fields = getJoinFieldNamesWithoutDatasetName(dataset, joinItems);
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return fields;
		// }
		//
		// /// <summary>
		// /// 获取指定图层的字段名以及所属数据集
		// /// 字段名带表名
		// /// </summary>
		// /// <param name="layer"></param>
		// /// <returns></returns>
		// public static Dictionary<String, DatasetVector>
		// getJoinFieldNamesAndDataset(Object layer)
		// {
		// Dictionary<String, DatasetVector> result = new Dictionary<String,
		// DatasetVector>();
		// try
		// {
		// List<DatasetVector> datasetList = getJoinDatasets(layer);
		// for (int i = 0; i < datasetList.Count; i++)
		// {
		// try
		// {
		// FieldInfos fieldInfos = datasetList.get(i).FieldInfos;
		// String datasetName =
		// String.IsNullOrEmpty(datasetList.get(i).TableName) ? "" :
		// datasetList.get(i).Name + ".";
		// for (int fieldIndex = 0; fieldIndex < fieldInfos.Count; fieldIndex++)
		// {
		// String fullFieldName = datasetName + fieldInfos[fieldIndex].Name;
		// result[fullFieldName] = datasetList.get(i);
		// }
		// }
		// catch
		// {
		//
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		//
		// return result;
		// }
		//
		// /// <summary>
		// /// 获取指定图层的字段名以及对应的字段信息
		// /// 字段名带表名
		// /// </summary>
		// /// <param name="layer"></param>
		// /// <returns></returns>
		// public static Dictionary<String, FieldInfo>
		// getJoinFieldNamesAndFieldInfo(Object layer)
		// {
		// Dictionary<String, FieldInfo> result = new Dictionary<String,
		// FieldInfo>();
		// try
		// {
		// List<DatasetVector> datasetList = getJoinDatasets(layer);
		// for (int i = 0; i < datasetList.Count; i++)
		// {
		// try
		// {
		// FieldInfos fieldInfos = datasetList.get(i).FieldInfos;
		// String datasetName =
		// String.IsNullOrEmpty(datasetList.get(i).TableName) ? "" :
		// datasetList.get(i).Name + ".";
		// for (int fieldIndex = 0; fieldIndex < fieldInfos.Count; fieldIndex++)
		// {
		// String fullFieldName = datasetName + fieldInfos[fieldIndex].Name;
		// result[fullFieldName] = fieldInfos[fieldIndex];
		// }
		// }
		// catch
		// {
		//
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		//
		// return result;
		// }
		//
		// /// <summary>
		// /// 获取指定图层关联的数据集集合
		// /// 数据集集合含外部连接表对应的数据集
		// /// </summary>
		// /// <param name="layer"></param>
		// /// <returns></returns>
		// public static List<DatasetVector> getJoinDatasets(Object layer)
		// {
		// List<DatasetVector> datasets = new List<DatasetVector>();
		// try
		// {
		// DatasetVector dataset = null;
		// if (layer is Layer)
		// {
		// dataset = (layer as Layer).Dataset as DatasetVector;
		// }
		// else if (layer is Layer3DDataset)
		// {
		// dataset = (layer as Layer3DDataset).Dataset as DatasetVector;
		// }
		// JoinItems joinItems = CommonToolkit.LayerWrap.getJoinItems(layer);
		// datasets = getJoinDatasets(dataset, joinItems);
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		//
		// return datasets;
		// }
		//
		// /// <summary>
		// /// 获取指定图层关联的数据集集合
		// /// 数据集集合含外部连接表对应的数据集
		// /// </summary>
		// /// <param name="layer"></param>
		// /// <returns></returns>
		// public static List<DatasetVector> getJoinDatasets(DatasetVector
		// dataset, JoinItems joinItems)
		// {
		// List<DatasetVector> datasets = new List<DatasetVector>();
		// try
		// {
		// datasets.Add(dataset);
		//
		// for (int i = 0; joinItems != null && i < joinItems.Count; i++)
		// {
		// JoinItem joinItem = joinItems.get(i);
		// String joinDatasetName = joinItem.ForeignTable;
		// DatasetVector joinDataset =
		// dataset.Datasource.Datasets[joinDatasetName] as DatasetVector;
		// if (joinDataset != null)
		// {
		// datasets.Add(joinDataset);
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		//
		// return datasets;
		// }
		//
		// /// <summary>
		// /// 获得一个矢量数据集带指定连接信息的记录集,同时输出带表名的字段名列表
		// /// </summary>
		// public static Recordset getJoinRecordset(DatasetVector dataset,
		// boolean onlyFieldInfos, JoinItems joinItems, out Dictionary<String,
		// String> resultFields)
		// {
		// Recordset recordset = null;
		// resultFields = null;
		// try
		// {
		// QueryParameter queryparameter = new QueryParameter();
		// queryparameter.CursorType = CursorType.Static;
		// queryparameter.HasGeometry = false;
		// queryparameter.JoinItems.AddRange(joinItems.ToArray());
		// resultFields = getJoinFieldNamesDic(dataset, joinItems);
		// int index = 0;
		// String[] resultFieldsName = new String[resultFields.Count];
		// queryparameter.ResultFields = new String[resultFields.Count];
		// foreach (KeyValuePair<String, String> item in resultFields)
		// {
		// resultFieldsName[index] = item.Value;
		// index++;
		// }
		// queryparameter.ResultFields = resultFieldsName;
		// if (onlyFieldInfos)
		// {
		// queryparameter.AttributeFilter = "1<0";
		// }
		// recordset = dataset.Query(queryparameter);
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return recordset;
		// }
		//
		//
		// /// <summary>
		// /// 获得一个带指定连接信息的矢量数据集的字段名集合，字段名包含表名
		// /// </summary>
		// public static List<String> getJoinFieldNames(DatasetVector dataset,
		// JoinItems joinItems)
		// {
		// List<String> resultFields = new List<String>();
		// try
		// {
		// List<DatasetVector> datasetList = getJoinDatasets(dataset,
		// joinItems);
		// //这里使用for循环，为了保证结果的顺序与获取字段集合的方法一致
		// for (int i = 0; i < datasetList.Count; i++)
		// {
		// try
		// {
		// FieldInfos fieldInfos = datasetList.get(i).FieldInfos;
		// String datasetName =
		// String.IsNullOrEmpty(datasetList.get(i).TableName) ? "" :
		// datasetList.get(i).Name + ".";
		// for (int fieldIndex = 0; fieldIndex < fieldInfos.Count; fieldIndex++)
		// {
		// //还原以前的表达式表示方法，用数据集名称 + 字段名
		// resultFields.Add(datasetName + fieldInfos[fieldIndex].Name);
		// }
		// }
		// catch
		// {
		//
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return resultFields;
		// }
		//
		// /// <summary>
		// /// 获得一个带指定连接信息的矢量数据集的字段名集合，字段名不包含表名
		// /// </summary>
		// /// <param name="dataset"></param>
		// /// <param name="joinItems"></param>
		// /// <returns></returns>
		// public static List<String>
		// getJoinFieldNamesWithoutDatasetName(DatasetVector dataset, JoinItems
		// joinItems)
		// {
		// List<String> resultFields = new List<String>();
		// try
		// {
		// List<DatasetVector> datasetList = getJoinDatasets(dataset,
		// joinItems);
		// //这里使用for循环，为了保证结果的顺序与获取字段集合的方法一致
		// for (int i = 0; i < datasetList.Count; i++)
		// {
		// try
		// {
		// FieldInfos fieldInfos = datasetList.get(i).FieldInfos;
		// for (int fieldIndex = 0; fieldIndex < fieldInfos.Count; fieldIndex++)
		// {
		// resultFields.Add(fieldInfos[fieldIndex].Name);
		// }
		// }
		// catch
		// {
		//
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return resultFields;
		// }
		//
		// public static Dictionary<String, String>
		// getJoinFieldNamesDic(DatasetVector dataset, JoinItems joinItems)
		// {
		// Dictionary<String, String> resultFields = new Dictionary<String,
		// String>();
		// try
		// {
		// List<DatasetVector> datasetList = getJoinDatasets(dataset,
		// joinItems);
		// //这里使用for循环，为了保证结果的顺序与获取字段集合的方法一致
		// for (int i = 0; i < datasetList.Count; i++)
		// {
		// try
		// {
		// FieldInfos fieldInfos = datasetList.get(i).FieldInfos;
		// String datasetName =
		// String.IsNullOrEmpty(datasetList.get(i).TableName) ? "" :
		// datasetList.get(i).Name + ".";
		// for (int fieldIndex = 0; fieldIndex < fieldInfos.Count; fieldIndex++)
		// {
		// //还原以前的表达式表示方法，用数据集名称 + 字段名
		// resultFields.Add(fieldInfos[fieldIndex].Name, datasetName +
		// fieldInfos[fieldIndex].Name);
		// }
		// }
		// catch
		// {
		//
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return resultFields;
		// }
		//
		// /// <summary>
		// /// 获取带指定连接信息的矢量数据集的字段集合
		// /// </summary>
		// /// <param name="dataset"></param>
		// /// <param name="joinItems"></param>
		// /// <returns></returns>
		// public static List<FieldInfo> getJoinFieldInfos(DatasetVector
		// dataset, JoinItems joinItems)
		// {
		// List<FieldInfo> resultFieldInfos = new List<FieldInfo>();
		// try
		// {
		// List<DatasetVector> datasetList = getJoinDatasets(dataset,
		// joinItems);
		// //这里使用for循环，为了保证结果的顺序与获取字段名集合的方法一致
		// for (int i = 0; i < datasetList.Count; i++)
		// {
		// try
		// {
		// FieldInfos dataFieldInfos = datasetList.get(i).FieldInfos;
		// for (int fieldIndex = 0; dataFieldInfos != null && fieldIndex <
		// dataFieldInfos.Count; fieldIndex++)
		// {
		// resultFieldInfos.Add(dataFieldInfos[fieldIndex]);
		// }
		// }
		// catch
		// {
		//
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return resultFieldInfos;
		// }

	}

	public static class RibbonWrap {

		// public static int ConvertStringToInt(String lab)
		// {
		// int index = int.MinValue;
		// try
		// {
		// if (lab != null && !lab.Equals(_XMLTag.g_Empty))
		// {
		// index = Convert.Toint(lab);
		// }
		// else
		// {
		// index = 0;
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// if (index == int.MinValue)
		// {
		// index = int.MaxValue;
		// }
		// return index;
		// }
		//
		// public static Bitmap getBitmap(String path)
		// {
		// Bitmap tempMap = null;
		// try
		// {
		// if (path != null && !path.Equals(_XMLTag.g_Empty))
		// {
		// String fullPath = CommonToolkit.PathWrap.getFullPathName(path);
		// if (System.IO.File.Exists(fullPath))
		// {
		// tempMap = new Bitmap(fullPath);
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return tempMap;
		// }

	}

	public static class ScaleWrap {

		// /// <summary>
		// /// 根据传入的字符串转换为正确的比例尺Double值
		// /// 例如：5000->0.0002；0.0005->0.0005；非数字->-1；-1000->-1
		// /// 1:5000->0.0002
		// /// </summary>
		// /// <param name="scaleString"></param>
		// /// <returns>-1表示转换失败</returns>
		// public static Double ConvertStringToScaleValue(String scaleString)
		// {
		// Double scaleValue = 0.0;
		// try
		// {
		// if (!Double.TryParse(scaleString, out scaleValue))
		// {
		// if (String.Compare(scaleString.Substring(0, 2), "1:",
		// StringComparison.CurrentCultureIgnoreCase) == 0)
		// {
		// scaleString = scaleString.Substring(2);
		// try
		// {
		// Double scaleTemp = Double.Parse(scaleString);
		// if (scaleTemp < 0)
		// {
		// scaleValue = -1;
		// }
		// else
		// {
		// scaleValue = 1 / scaleTemp;
		// }
		// }
		// catch
		// {
		// scaleValue = -1;
		// }
		// }
		// else
		// {
		// scaleValue = -1;
		// }
		// }
		// else
		// {
		// if (scaleValue < 0)
		// {
		// scaleValue = -1;
		// }
		// else if (scaleValue > 1)
		// {
		// scaleValue = 1 / scaleValue;
		// }
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// scaleValue = -1;
		// }
		//
		// return scaleValue;
		// }
		//
		// /// <summary>
		// /// 根据传入的数值转换为正确的比例尺数值
		// /// 规则：大于1，返回倒数值；小于0，返回-1；其他，保持原样。
		// /// </summary>
		// /// <param name="scale"></param>
		// /// <returns></returns>
		// public static Double ConvertStringToScaleValue(Double scale)
		// {
		// Double scaleValue = 0.0;
		// try
		// {
		// if (scaleValue < 0)
		// {
		// scaleValue = -1;
		// }
		// else if (scaleValue > 1)
		// {
		// scaleValue = 1 / scaleValue;
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// scaleValue = -1;
		// }
		//
		// return scaleValue;
		// }
		//
		// /// <summary>
		// /// 根据一定规则将传入的字符串转换为比例尺表示形式
		// ///
		// 规则：1:1000->1:1000；5000->1:0.0002；0.5->1:2；-1->String.Empty；asd->String.Empty
		// /// </summary>
		// /// <param name="scaleString"></param>
		// /// <returns></returns>
		// public static String ConvertStringToScale(String scaleString)
		// {
		// String scale = String.Empty;
		// try
		// {
		// if (!String.IsNullOrEmpty(scaleString))
		// {
		// Double scaleValue = 0;
		// if (!Double.TryParse(scaleString, out scaleValue))
		// {
		// if (String.Compare(scaleString.Substring(0, 2), "1:",
		// StringComparison.CurrentCultureIgnoreCase) == 0)
		// {
		// String scaleStringTemp = scaleString.Substring(3);
		// try
		// {
		// Double scaleTemp = Double.Parse(scaleStringTemp);
		// if (scaleTemp < 0)
		// {
		// scale = String.Empty;
		// }
		// else
		// {
		// scale = scaleString;
		// }
		// }
		// catch
		// {
		// scale = String.Empty;
		// }
		// }
		// else
		// {
		// scale = String.Empty;
		// }
		// }
		// else
		// {
		// if (scaleValue < 0)
		// {
		// scale = String.Empty;
		// }
		// else if (scaleValue < Math.Pow(Math.E, -10))
		// {
		// scale = "0";
		// }
		// else if (scaleValue > 1)
		// {
		// scale = String.format("1:{0}", scaleString);
		// }
		// else
		// {
		// scale = String.format("1:{0}", (1 / scaleValue).ToString());
		// }
		// }
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// scale = String.Empty;
		// }
		//
		// return scale;
		// }
		//
		// public static String ConvertStringToScale(Double scaleValue)
		// {
		// String scale = String.Empty;
		// try
		// {
		// if (scaleValue < 0)
		// {
		// scale = String.Empty;
		// }
		// else if (scaleValue < Math.Pow(10, -10))
		// {
		// scale = "0";
		// }
		// else if (scaleValue > 1)
		// {
		// scale = String.format("1:{0}", scaleValue.ToString());
		// }
		// else
		// {
		// scale = String.format("1:{0}", (1 / scaleValue).ToString());
		// }
		// }catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		//
		// return scale;
		// }

	}

	public static class SceneWrap {
		/**
		 * 判断场景新名称是否可用
		 * 
		 * @param newSceneName
		 * @param oldSceneName
		 * @return
		 */
		public static boolean checkAvailableSceneName(String newSceneName, String oldSceneName) {
			boolean flag = false;
			newSceneName = newSceneName.toLowerCase();
			oldSceneName = oldSceneName.toLowerCase();
			if (null == newSceneName || newSceneName.length() <= 0) {
				flag = false;
			} else {
				ArrayList<String> allSceneNames = new ArrayList<String>();

				for (int index = 0; index < Application.getActiveApplication().getWorkspace().getScenes().getCount(); index++) {
					allSceneNames.add(Application.getActiveApplication().getWorkspace().getScenes().get(index).toLowerCase());
				}

				for (int index = 0; index < Application.getActiveApplication().getMainFrame().getFormManager().getCount(); index++) {
					IForm form = Application.getActiveApplication().getMainFrame().getFormManager().get(index);
					if (!form.getText().equalsIgnoreCase(oldSceneName)) {
						allSceneNames.add(form.getText().toLowerCase());
					}
				}
				if (!allSceneNames.contains(newSceneName)) {
					flag = true;
				}
			}

			return flag;
		}

		/**
		 * 在当前的工作空间中获取一个唯一可用的场景名称
		 * 
		 * @param sceneName 指定前缀
		 * @param bNewWindow 是否是新窗口
		 * @return
		 */
		public static String getAvailableSceneName(String sceneName, boolean isNewWindow) {
			String availableSceneName = sceneName.toLowerCase();
			if (null == sceneName || sceneName.length() <= 0) {
				sceneName = CoreProperties.getString("String_WorkspaceNodeCaptionScene");
			}

			ArrayList<String> allSceneNames = new ArrayList<String>();

			for (int index = 0; index < Application.getActiveApplication().getWorkspace().getScenes().getCount(); index++) {
				allSceneNames.add(Application.getActiveApplication().getWorkspace().getScenes().get(index).toLowerCase());
			}

			for (int index = 0; index < Application.getActiveApplication().getMainFrame().getFormManager().getCount(); index++) {
				IForm form = Application.getActiveApplication().getMainFrame().getFormManager().get(index);
				if (form instanceof IFormScene) {
					allSceneNames.add(form.getText().toLowerCase());
				}
			}

			if (!allSceneNames.contains(availableSceneName)) {
				availableSceneName = sceneName;
			} else {
				int indexSceneName = 1;
				while (true) {
					availableSceneName = String.format("%s%d", sceneName, indexSceneName);
					availableSceneName = availableSceneName.toLowerCase();
					if (!allSceneNames.contains(availableSceneName)) {
						break;
					}

					indexSceneName += 1;
				}
			}

			return availableSceneName;
		}

		/**
		 * 删除指定的场景
		 * 
		 * @param sceneNames
		 */
		public static void deleteScenes(String[] sceneNames) {
			try {
				String message = CoreProperties.getString("String_SceneDelete_Confirm");
				if (sceneNames.length == 1) {
					message = message + "\r\n" + String.format(CoreProperties.getString("String_SceneDelete_Confirm_One"), sceneNames[0]);
				} else {
					message = message + "\r\n" + String.format(CoreProperties.getString("String_SceneDelete_Confirm_Multi"), sceneNames.length);
				}

				if (JOptionPane.showConfirmDialog(null, message, CoreProperties.getString("String_SceneDelete"), JOptionPane.OK_CANCEL_OPTION,
						JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
					for (String sceneName : sceneNames) {
						Application.getActiveApplication().getWorkspace().getScenes().remove(sceneName);
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
		}

		public static void flyToObject(Scene scene, Geometry geometry, int timeSpan) {
			if (scene != null && geometry != null) {
				if (geometry.getBounds().getWidth() == 0 && geometry.getBounds().getHeight() == 0) {
					Camera flyCamera = scene.getCamera();
					flyCamera.setLongitude(geometry.getInnerPoint().getX());
					flyCamera.setLatitude(geometry.getInnerPoint().getY());
					flyCamera.setAltitude(1000);
					scene.fly(flyCamera, timeSpan);
				} else {
					scene.ensureVisible(geometry.getBounds(), timeSpan);
				}
			}
		}

		public static void flyToObject(Scene scene, Geometry geometry) {
			if (scene != null && geometry != null) {
				if (geometry.getBounds().getWidth() == 0 && geometry.getBounds().getHeight() == 0) {
					Camera flyCamera = scene.getCamera();
					flyCamera.setLongitude(geometry.getInnerPoint().getX());
					flyCamera.setLatitude(geometry.getInnerPoint().getY());
					flyCamera.setAltitude(1000);
					scene.fly(flyCamera);
				} else {
					scene.ensureVisible(geometry.getBounds());
				}
			}
		}
	}

	public static class SpatialIndexTypeWrap {

		// /// <summary>
		// /// 根据指定的扩展名判断文件类型是否被桌面支持
		// /// </summary>
		// public static boolean IsSuportedFileExt(String fileExt)
		// {
		// boolean result = false;
		// if (fileExt.Equals(".sxw") ||
		// fileExt.Equals(".smw") ||
		// fileExt.Equals(".smwu") ||
		// fileExt.Equals(".sxwu"))
		// {
		// result = true;
		// }
		// else
		// {
		// result = DatasourceWrap.IsSuportedFileEngineExt(fileExt);
		// }
		// return result;
		// }
		//
		// /// <summary>
		// /// 根据指定的栅格文件扩展名获取对应的栅格扩展名描述
		// /// </summary>
		// public static String getImagePluginsName(String fileExt)
		// {
		// String strname = "Image Plugin Data Engine";
		// try
		// {
		// switch (fileExt)
		// {
		// case "*.sit":
		// {
		// strname = "Image Tower";
		// }
		// break;
		// case "*.bmp":
		// {
		// strname = "BMP Image";
		// }
		// break;
		// case "*.jpg":
		// {
		// strname = "JPG Image";
		// }
		// break;
		// case "*.gif":
		// {
		// strname = "GIF Image";
		// }
		// break;
		// case "*.png":
		// {
		// strname = "PNG Image";
		// }
		// break;
		// case "*.tif":
		// {
		// strname = "TIF Image";
		// }
		// break;
		// case "*.img":
		// {
		// strname = "IMG Image";
		// }
		// break;
		// case "*.sci":
		// {
		// strname = "Cache Image";
		// }
		// break;
		// }
		// }
		// catch
		// {
		//
		// }
		// return strname;
		// }
		//
		// /// <summary>
		// /// 根据指定的几何对象类型获取对应的模板风格资源字符串表示
		// /// </summary>
		// public static String getStyleTemplateString(GeometryType
		// geometryType)
		// {
		// String strTitle = String.Empty;
		// try
		// {
		// switch (geometryType)
		// {
		// case GeometryType.GeoLine:
		// {
		// strTitle = CoreResources.String_LineStyleTemplateTitle;
		// }
		// break;
		// case GeometryType.GeoPoint:
		// {
		// strTitle = CoreResources.String_PointStyleTemplateTitle;
		// }
		// break;
		// case GeometryType.GeoRegion:
		// {
		// strTitle = CoreResources.String_RegionStyleTemplateTitle;
		// }
		// break;
		// case GeometryType.GeoText:
		// {
		// strTitle = CoreResources.String_TextStyleTemplateTitle;
		// }
		// break;
		//
		// default:
		// {
		// }
		// break;
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return strTitle;
		// }
	}

	public static class SymbolLibraryWrap {
		//
		// private static String chartMarkerFile =
		// "./Resource/Chart/Presentation/S52/SymbolLib/Marker.sym";
		// private static String chartLineFile =
		// "./Resource/Chart/Presentation/S52/SymbolLib/Line.lsl";
		// private static String chartFillFile =
		// "./Resource/Chart/Presentation/S52/SymbolLib/Fill.bru";

		// public static String getLibPath(SymbolLibrary symbolLibray)
		// {
		// return symbolLibray.getLibPath();
		// }
		//
		// /// <summary>
		// /// 加载海图符号库
		// /// </summary>
		// public static void LoadChartSymbolLib()
		// {
		// try
		// {
		// String fileName =
		// CommonToolkit.PathWrap.getFullPathName(chartMarkerFile);
		// if (File.Exists(fileName))
		// {
		// ImportSymbolLibrary(Application.getActiveApplication().getWorkspace().Resources.MarkerLibrary,
		// fileName);
		// }
		//
		// fileName = CommonToolkit.PathWrap.getFullPathName(chartLineFile);
		// if (File.Exists(fileName))
		// {
		// ImportSymbolLibrary(Application.getActiveApplication().getWorkspace().Resources.LineLibrary,
		// fileName);
		// }
		//
		// fileName = CommonToolkit.PathWrap.getFullPathName(chartFillFile);
		// if (File.Exists(fileName))
		// {
		// ImportSymbolLibrary(Application.getActiveApplication().getWorkspace().Resources.FillLibrary,
		// fileName);
		// }
		//
		// //Application.getActiveApplication().Output.Output(CoreResources.String_LoadChartResourcesSuccess);
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// }
		//
		// /// <summary>
		// /// 导入指定文件路径的符号库
		// /// </summary>
		// private static void ImportSymbolLibrary(SymbolLibrary currentLib,
		// String fileName)
		// {
		// try
		// {
		// SymbolGroup currentGroup = currentLib.RootGroup;
		// Resources resouces = new Resources();
		// SymbolLibrary lib = null;
		// if (currentLib is SymbolMarkerLibrary)
		// {
		// lib = resouces.MarkerLibrary;
		// }
		// else if (currentLib is SymbolLineLibrary)
		// {
		// lib = resouces.LineLibrary;
		// }
		// else if (currentLib is SymbolFillLibrary)
		// {
		// lib = resouces.FillLibrary;
		// }
		//
		// if (lib != null &&
		// lib.FromFile(fileName))
		// {
		// if (currentLib is SymbolLineLibrary)
		// {
		// //CheckLineLibUsedInlineMarkers(lib.RootGroup, new Dictionary<int,
		// int>(), resouces.LineLibrary.InlineMarkerLib, (lib as
		// SymbolLineLibrary).InlineMarkerLib);
		// }
		// else if (currentLib is SymbolFillLibrary)
		// {
		// //CheckFillLibUsedInlineMarkers(lib.RootGroup, new Dictionary<int,
		// int>(), resouces.FillLibrary.InlineMarkerLib, (lib as
		// SymbolFillLibrary).InlineMarkerLib);
		// }
		//
		// if (lib.RootGroup.ChildGroups.Count > 0)
		// {
		// AppendSymbolGroup(currentGroup, lib.RootGroup.ChildGroups[0]);
		// }
		// else
		// {
		// AppendSymbolGroup(currentGroup, lib.RootGroup);
		// }
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// }
		//
		// /// <summary>
		// /// 附加指定的符号库分组到某符号库父目录下。
		// /// </summary>
		// private static SymbolGroup AppendSymbolGroup(SymbolGroup
		// symbolGroupParent, SymbolGroup symbolGroupSrc)
		// {
		// SymbolGroup symbolGroup = null;
		// try
		// {
		// String groupName = symbolGroupSrc.Name;
		// if (groupName.Length == 0)
		// {
		// //groupName = CoreResources.String_ChildGroup;
		// }
		//
		// if (symbolGroupParent.ChildGroups.Contains(groupName))
		// {
		// symbolGroup = symbolGroupParent.ChildGroups[groupName];
		// }
		// else
		// {
		// symbolGroup = symbolGroupParent.ChildGroups.Create(groupName);
		// }
		//
		// for (int index = 0; index < symbolGroupSrc.Count; index++)
		// {
		// int idSrc = symbolGroupSrc[index].ID;
		// if (symbolGroup.Library.Contains(idSrc))
		// {
		// symbolGroup.Library.Remove(idSrc);
		// }
		// symbolGroup.Library.Add(symbolGroupSrc[index], symbolGroup);
		// }
		//
		// for (int index = 0; index < symbolGroupSrc.ChildGroups.Count;
		// index++)
		// {
		// AppendSymbolGroup(symbolGroup, symbolGroupSrc.ChildGroups[index]);
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return symbolGroup;
		// }
		//
		// /// <summary>
		// /// 获取某符号库父目录下的可用符号库名
		// /// </summary>
		// private static void getAvailableGroupName(SymbolGroup
		// symbolGroupParent, ref String strName)
		// {
		// try
		// {
		// SymbolGroups symbolGroups = symbolGroupParent.ChildGroups;
		// String availableName = strName;
		// String name = strName;
		// int nCount = 0;
		// int nIndex = 0;
		//
		// while (symbolGroups != null && symbolGroups.Contains(strName))
		// {
		// int i = strName.LastIndexOf("_");
		//
		// if (i > -1)
		// {
		// if (i == strName.Length - 1)
		// {
		// availableName = strName + "1";
		// }
		// else
		// {
		// String endStr = strName.Substring(i + 1);
		// String beginStr = strName.Substring(0, i + 1);
		// int nValue = 0;
		// if (int.TryParse(endStr, out nValue))
		// {
		// nValue++;
		// endStr = nValue.ToString();
		// }
		// else
		// {
		// endStr = endStr + "_1";
		// }
		//
		// availableName = beginStr + endStr;
		// }
		// }
		// else
		// {
		// availableName = strName + "_1";
		// }
		//
		// nCount++;
		//
		// // 用于处理名称超长的情况
		// if (nCount > 100)
		// {
		// nIndex++; // 记录进入此if的次数
		//
		// if (nIndex < name.Length - 1)
		// {
		// availableName = name.Substring(0, name.Length - 1 - nIndex);
		// nCount = 0;
		// }
		// else
		// {
		// //availableName = CoreResources.String_ChildGroup;
		// }
		// }
		//
		// strName = availableName;
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// }
		//
		// /// <summary>
		// /// 判断一个符号对象是否栅格符号。
		// /// </summary>
		// public static boolean IsRasterMarker(Symbol symbol)
		// {
		// boolean isRasterMarker = false;
		// SymbolMarker marker = symbol as SymbolMarker;
		// if ((symbol.getType() != SymbolType.Marker3D) //三维符号实现和栅格符号相同，所以排除
		// && marker.Count == 1 // 栅格符号只有一个笔划为Bitmap或者Icon类型
		// && (marker[0].getType() == StrokeType.Bitmap || marker[0].getType()
		// ==
		// StrokeType.Icon))
		// {
		// isRasterMarker = true;
		// }
		// return isRasterMarker;
		// }
	}

	public static class ThemeStyleWrap {
		// public static event ThemeStyleChangedEventHandler
		// ThemeStyleChangedEvent;
		// #region Variable
		// private static ThemeStyle currentThemeStyle;
		// #endregion
		// /// <summary>
		// /// 获取或设置桌面当前的主题风格
		// /// </summary>
		// public static ThemeStyle CurrentThemeStyle
		// {
		// get
		// {
		// return currentThemeStyle;
		// }
		// set
		// {
		// currentThemeStyle = value;
		// if (ThemeStyleChangedEvent != null)
		// {
		// ThemeStyleChangedEvent(null, new
		// ThemeStyleChangedEventArgs(currentThemeStyle, value));
		// }
		// }
		// }
		// #region Property
		//
		// #endregion
		//
		// #region Construct
		//
		// #endregion
		//
		// #region Function_Public
		// /// <summary>
		// /// 获取桌面当前主题风格的活动窗体字体
		// /// </summary>
		// public static Font getRibbonFont()
		// {
		// Font result = SystemFonts.DefaultFont;
		//
		// try
		// {
		// if (CurrentThemeStyle != null)
		// {
		// if (CurrentThemeStyle.PanelStyle.InnerAreaStyleType !=
		// InnerAreaStyleType.UseInnerStyle)
		// {
		// result = SystemFonts.DefaultFont;
		// }
		// else
		// {
		// result = CurrentThemeStyle.PanelStyle.InnerAreaStyle.Font;
		// }
		// //result = CurrentThemeStyle.RibbonStyle.Font;
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return result;
		// }
		//
		// /// <summary>
		// /// 将Desktop的UIInnerThemeStyle转为Janus的UIformatStyle
		// /// </summary>
		// public static void
		// SetUIPanelInnerStyle(Janus.Windows.UI.UIformatStyle style,
		// UIInnerThemeStyle theme)
		// {
		// try
		// {
		// if (null == style || null == theme)
		// {
		// return;
		// }
		// style.Alpha = CommonToolkit.ColorWrap.getAlphaFromOpaqueRate(0);
		// style.BackColor = theme.BackColor;
		// style.BackColorAlphaMode = Janus.Windows.UI.AlphaMode.UseAlpha;
		// style.BackColorGradient = theme.BackColor;
		// style.BackgroundGradientMode =
		// (Janus.Windows.UI.BackgroundGradientMode)theme.BackgroundGradientMode;
		// style.BackgroundImage = theme.BackgroundImage;
		// style.BackgroundImageDrawMode =
		// (Janus.Windows.UI.BackgroundImageDrawMode)theme.BackgroundImageDrawMode;
		// style.Blend = theme.Blend;
		// style.BlendGradient = theme.BlendGradient;
		// style.Font = theme.Font;
		// style.ForeColor = theme.ForeColor;
		// style.ForeColorAlphaMode = Janus.Windows.UI.AlphaMode.UseAlpha;
		// }
		// catch
		// {
		//
		// }
		// }
		//
		// /// <summary>
		// /// 将Desktop的UIWindowTabThemeStyle转为Janus的UIformatStyle
		// /// </summary>
		// public static void SetUIWindowTabStyle(Janus.Windows.UI.UIformatStyle
		// style, UITabThemeStyle source)
		// {
		// if (null == source || null == style)
		// {
		// return;
		// }
		// style.BackColor = source.BackColor;
		// style.BackColorGradient = source.BackColorGradient;
		// style.Blend = source.Blend;
		// style.BlendGradient = source.BlendGradient;
		// style.Font = source.Font;
		// style.ForeColor = source.ForeColor;
		// }
	}

	public static class ThreadWrap {

		// public static Thread CreateThread(ThreadStart threadStart)
		// {
		// try
		// {
		// Thread thread = new Thread(threadStart);
		// try
		// {
		// //以下2个值必须保持一致，不然会出现错误，比如 土耳其+en 的组合，原因不在此详述
		// //设置当前线程的语言文化环境，用以正确处理字符串、数值转换，字符串比较等
		// thread.CurrentCulture =
		// CultureInfo.getCultureInfo(_XMLTag.g_strCurrentCulture);
		// //设置应用程序显示区域语言，用以加载对应的资源文件
		// thread.CurrentUICulture =
		// CultureInfo.getCultureInfo(_XMLTag.g_strCurrentUICulture);
		// }
		// catch
		// {
		// thread.CurrentCulture = CultureInfo.getCultureInfo("zh-CN");
		// thread.CurrentUICulture = CultureInfo.getCultureInfo("zh-CN");
		// }
		//
		// return thread;
		// }
		// catch (Exception ex)
		// {
		// return null;
		// throw ex;
		// }
		// }
		//
		// public static Thread CreateThread(ParameterizedThreadStart
		// threadStart)
		// {
		// try
		// {
		// Thread thread = new Thread(threadStart);
		// try
		// {
		// //以下2个值必须保持一致，不然会出现错误，比如 土耳其+en 的组合，原因不在此详述
		// //设置当前线程的语言文化环境，用以正确处理字符串、数值转换，字符串比较等
		// thread.CurrentCulture =
		// CultureInfo.getCultureInfo(_XMLTag.g_strCurrentCulture);
		// //设置应用程序显示区域语言，用以加载对应的资源文件
		// thread.CurrentUICulture =
		// CultureInfo.getCultureInfo(_XMLTag.g_strCurrentUICulture);
		// }
		// catch
		// {
		// thread.CurrentCulture = CultureInfo.getCultureInfo("zh-CN");
		// thread.CurrentUICulture = CultureInfo.getCultureInfo("zh-CN");
		// }
		//
		// return thread;
		// }
		// catch (Exception ex)
		// {
		// return null;
		// throw ex;
		// }
		// }
	}

	public static class UndefinedWrap {

		// /// <summary>
		// /// 根据指定的扩展名判断文件类型是否被桌面支持
		// /// </summary>
		// public static boolean IsSuportedFileExt(String fileExt)
		// {
		// boolean result = false;
		// if (fileExt.Equals(".sxw") ||
		// fileExt.Equals(".smw") ||
		// fileExt.Equals(".smwu") ||
		// fileExt.Equals(".sxwu"))
		// {
		// result = true;
		// }
		// else
		// {
		// result = DatasourceWrap.IsSuportedFileEngineExt(fileExt);
		// }
		// return result;
		// }
		//
		// /// <summary>
		// /// 根据指定的栅格文件扩展名获取对应的栅格扩展名描述
		// /// </summary>
		// public static String getImagePluginsName(String fileExt)
		// {
		// String strname = "Image Plugin Data Engine";
		// try
		// {
		// switch (fileExt)
		// {
		// case "*.sit":
		// {
		// strname = "Image Tower";
		// }
		// break;
		// case "*.bmp":
		// {
		// strname = "BMP Image";
		// }
		// break;
		// case "*.jpg":
		// {
		// strname = "JPG Image";
		// }
		// break;
		// case "*.gif":
		// {
		// strname = "GIF Image";
		// }
		// break;
		// case "*.png":
		// {
		// strname = "PNG Image";
		// }
		// break;
		// case "*.tif":
		// {
		// strname = "TIF Image";
		// }
		// break;
		// case "*.img":
		// {
		// strname = "IMG Image";
		// }
		// break;
		// case "*.sci":
		// {
		// strname = "Cache Image";
		// }
		// break;
		// }
		// }
		// catch
		// {
		//
		// }
		// return strname;
		// }
		//
		// /// <summary>
		// /// 根据指定的几何对象类型获取对应的模板风格资源字符串表示
		// /// </summary>
		// public static String getStyleTemplateString(GeometryType
		// geometryType)
		// {
		// String strTitle = String.Empty;
		// try
		// {
		// switch (geometryType)
		// {
		// case GeometryType.GeoLine:
		// {
		// strTitle = CoreResources.String_LineStyleTemplateTitle;
		// }
		// break;
		// case GeometryType.GeoPoint:
		// {
		// strTitle = CoreResources.String_PointStyleTemplateTitle;
		// }
		// break;
		// case GeometryType.GeoRegion:
		// {
		// strTitle = CoreResources.String_RegionStyleTemplateTitle;
		// }
		// break;
		// case GeometryType.GeoText:
		// {
		// strTitle = CoreResources.String_TextStyleTemplateTitle;
		// }
		// break;
		//
		// default:
		// {
		// }
		// break;
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return strTitle;
		// }
	}

	public static class UnitWrap {

		// #region Variable
		// private static Dictionary<Unit, String> distanceUnitNames;
		// private static Dictionary<AreaUnit, String> areaUnitNames;
		// private static Dictionary<Unit, String> volumnUnitNames;
		// public static Dictionary<Degreeformat, String> degreeformatNames;
		// #endregion
		//
		// #region Property
		// /// <summary>
		// /// 距离单位与引用资源字典
		// /// </summary>
		// public static Dictionary<Unit, String> DistanceUnitNames
		// {
		// get
		// {
		// return distanceUnitNames;
		// }
		// }
		//
		// /// <summary>
		// /// 面积单位与引用资源字典
		// /// </summary>
		// public static Dictionary<AreaUnit, String> AreaUnitNames
		// {
		// get
		// {
		// return areaUnitNames;
		// }
		// }
		//
		// /// <summary>
		// /// 体积单位与引用资源字典
		// /// </summary>
		// public static Dictionary<Unit, String> VolumnUnitNames
		// {
		// get
		// {
		// return volumnUnitNames;
		// }
		// }
		// #endregion
		//
		// #region Construct
		// static UnitWrap()
		// {
		// Initialize();
		// }
		// #endregion
		//
		// #region Function_Public
		// /// <summary>
		// /// 根据距离单位类型获取对应的资源字符串
		// /// </summary>
		// public static String getDistanceUnitName(Unit unit)
		// {
		// String strName = CoreResources.String_Unknown;//"Unknown";
		// try
		// {
		// strName = distanceUnitNames[unit];
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return strName;
		// }
		//
		// /// <summary>
		// /// 根据面积单位类型获取对应的资源字符串
		// /// </summary>
		// public static String getAreaUnitName(Unit unit)
		// {
		// String strName = CoreResources.String_Unknown;
		// try
		// {
		// AreaUnit areaUnit = getAreaUnitByLengthUnit(unit);
		// strName = areaUnitNames[areaUnit];
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return strName;
		// }
		//
		//
		// private static Unit getUnitByAreaUnit(AreaUnit areaUnit)
		// {
		// Unit unit = Unit.Meter;
		// try
		// {
		// switch (areaUnit)
		// {
		// case AreaUnit.Millimeter:
		// unit = Unit.Millimeter;
		// break;
		// case AreaUnit.Centimeter:
		// unit = Unit.Centimeter;
		// break;
		// case AreaUnit.Inch:
		// unit = Unit.Inch;
		// break;
		// case AreaUnit.Decimeter:
		// unit = Unit.Decimeter;
		// break;
		// case AreaUnit.Foot:
		// unit = Unit.Foot;
		// break;
		// case AreaUnit.Yard:
		// unit = Unit.Yard;
		// break;
		// case AreaUnit.Meter:
		// unit = Unit.Meter;
		// break;
		// case AreaUnit.Kilometer:
		// unit = Unit.Kilometer;
		// break;
		// case AreaUnit.Mile:
		// unit = Unit.Mile;
		// break;
		// case AreaUnit.Second:
		// unit = Unit.Second;
		// break;
		// case AreaUnit.Minute:
		// unit = Unit.Minute;
		// break;
		// case AreaUnit.Degree:
		// unit = Unit.Degree;
		// break;
		// case AreaUnit.Radian:
		// unit = Unit.Radian;
		// break;
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return unit;
		// }
		//
		// private static AreaUnit getAreaUnitByLengthUnit(Unit unit)
		// {
		// AreaUnit areaUnit = AreaUnit.Meter;
		// try
		// {
		// switch (unit)
		// {
		// case Unit.Millimeter:
		// areaUnit = AreaUnit.Millimeter;
		// break;
		// case Unit.Centimeter:
		// areaUnit = AreaUnit.Centimeter;
		// break;
		// case Unit.Inch:
		// areaUnit = AreaUnit.Inch;
		// break;
		// case Unit.Decimeter:
		// areaUnit = AreaUnit.Decimeter;
		// break;
		// case Unit.Foot:
		// areaUnit = AreaUnit.Foot;
		// break;
		// case Unit.Yard:
		// areaUnit = AreaUnit.Yard;
		// break;
		// case Unit.Meter:
		// areaUnit = AreaUnit.Meter;
		// break;
		// case Unit.Kilometer:
		// areaUnit = AreaUnit.Kilometer;
		// break;
		// case Unit.Mile:
		// areaUnit = AreaUnit.Mile;
		// break;
		// case Unit.Second:
		// areaUnit = AreaUnit.Second;
		// break;
		// case Unit.Minute:
		// areaUnit = AreaUnit.Minute;
		// break;
		// case Unit.Degree:
		// areaUnit = AreaUnit.Degree;
		// break;
		// case Unit.Radian:
		// areaUnit = AreaUnit.Radian;
		// break;
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return areaUnit;
		// }
		//
		// /// <summary>
		// /// 根据体积单位类型获取对应的资源字符串
		// /// </summary>
		// public static String getVolumnUnitName(Unit unit)
		// {
		// String strName = CoreResources.String_Unknown;
		// try
		// {
		// strName = volumnUnitNames[unit];
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return strName;
		// }
		//
		// /// <summary>
		// /// 根据角度单位类型获取对应的资源字符串
		// /// </summary>
		// public static String getDegreeformatName(Degreeformat format)
		// {
		// String strName = CoreResources.String_Unknown;
		// try
		// {
		// strName = degreeformatNames[format];
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		//
		// return strName;
		// }
		//
		// /// <summary>
		// /// 根据距离单位的本地化名称，获取距离单位的类型
		// /// </summary>
		// public static Unit getDistanceUnitType(String name)
		// {
		// Unit result = Unit.Meter;
		//
		// try
		// {
		// foreach (KeyValuePair<Unit, String> kvp in distanceUnitNames)
		// {
		// // 先判断我们自己给的名字是否存在 [12/28/2011 zhoujt]
		// if (kvp.Value.ToUpper().Equals(name.ToUpper()))
		// {
		// result = kvp.Key;
		// break;
		// }
		//
		// // 为了防止直接用枚举名称来标示名字，再匹配一下key值 [12/28/2011 zhoujt]
		// if (kvp.Key.ToString().ToUpper().Equals(name.ToUpper()))
		// {
		// result = kvp.Key;
		// break;
		// }
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return result;
		// }
		//
		// public static AreaUnit getAreaUnitTypeByName(String name)
		// {
		// AreaUnit areaUnit = AreaUnit.Meter;
		// try
		// {
		// foreach (KeyValuePair<AreaUnit, String> kvp in areaUnitNames)
		// {
		// if (kvp.Value.Equals(name))
		// {
		// areaUnit = kvp.Key;
		// break;
		// }
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return areaUnit;
		// }
		//
		// /// <summary>
		// /// 根据面积单位的本地化名称，获取距离单位的类型
		// /// </summary>
		// public static Unit getAreaUnitType(String name)
		// {
		// Unit result = Unit.Meter;
		// try
		// {
		// foreach (KeyValuePair<AreaUnit, String> kvp in areaUnitNames)
		// {
		// if (kvp.Value.Equals(name))
		// {
		// result = getUnitByAreaUnit(kvp.Key);
		// break;
		// }
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return result;
		// }
		//
		// /// <summary>
		// /// 根据体积单位的本地化名称，获取距离单位的类型
		// /// </summary>
		// public static Unit getVolumnUnitType(String name)
		// {
		// Unit result = Unit.Meter;
		// try
		// {
		// foreach (KeyValuePair<Unit, String> kvp in volumnUnitNames)
		// {
		// if (kvp.Value.Equals(name))
		// {
		// result = kvp.Key;
		// break;
		// }
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return result;
		// }
		//
		// /// <summary>
		// /// 根据角度单位的本地化名称，获取距离单位的类型
		// /// </summary>
		// public static Degreeformat getDegreeformatType(String name)
		// {
		// Degreeformat result = Degreeformat.Degree;
		//
		// try
		// {
		// foreach (KeyValuePair<Degreeformat, String> kvp in
		// degreeformatNames)
		// {
		// if (kvp.Value.Equals(name))
		// {
		// result = kvp.Key;
		// break;
		// }
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return result;
		// }
		//
		// /// <summary>
		// /// 根据指定的角度单位格式化角度数值
		// /// </summary>
		// public static String formatDegree(Degreeformat degreeformat, Double
		// degree)
		// {
		// String resultDegree = String.Empty;
		// try
		// {
		// switch (degreeformat)
		// {
		// case Degreeformat.Degree:
		// {
		// resultDegree = String.format("{0:F6}{1}", degree,
		// CommonResources.String_AngleUnit_Degree);
		// }
		// break;
		// case Degreeformat.DDMMSS:
		// {
		// //int degreeSegment = Convert.Toint(degree);
		// //int minuteSegment = Convert.Toint((degree - degreeSegment) * 60);
		// //Double secondSegment = ((degree - degreeSegment) * 60 -
		// minuteSegment) * 60;
		//
		// //resultDegree = String.format("{0}{1}{2}{3}{4}{5}",
		// // degreeSegment, CommonResources.String_AngleUnit_Degree,
		// // minuteSegment, CommonResources.String_AngleUnit_Minute,
		// // secondSegment, CommonResources.String_AngleUnit_Second);
		//
		// boolean isNegative = (degree < 0);
		// if (isNegative)
		// {
		// degree = Math.Abs(degree);
		// }
		// Double degreeSegment = Math.Floor(degree);
		// Double minuteSegment = Math.Floor((degree - degreeSegment) * 60);
		// Double secondSegment = ((degree - degreeSegment) * 60 -
		// minuteSegment) * 60;
		//
		// if (isNegative)
		// {
		// degreeSegment = -degreeSegment;
		// }
		// resultDegree = String.format("{0}{1}{2}{3}{4:F2}{5}",
		// degreeSegment.ToString("0"), CommonResources.String_AngleSign_Degree,
		// minuteSegment.ToString("0"), CommonResources.String_AngleSign_Minute,
		// secondSegment, CommonResources.String_AngleSign_Second);
		// }
		// break;
		// case Degreeformat.Radian:
		// {
		// resultDegree = String.format("{0:F6}{1}", (degree * Math.PI / 180.0),
		// CommonResources.String_AngleUnit_Radian);
		// }
		// break;
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return resultDegree;
		// }
		//
		// /// <summary>
		// /// 以指定单位作为参照，进行距离单位换算
		// /// </summary>
		// public static Double ConvertDistance(Unit srcUnit, Unit desUnit,
		// Double distance)
		// {
		// Double resultDistance = distance;
		// try
		// {
		// if (srcUnit != desUnit) // 两种单位不相同时才进行转换
		// {
		// resultDistance = distance * ((Double)srcUnit / (Double)desUnit);
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return resultDistance;
		// }
		//
		// /// <summary>
		// /// 以投影系统的坐标单位作为参照，进行距离单位换算，平面坐标系使用坐标单位，其他坐标系单位默认为米
		// /// </summary>
		// public static Double ConvertDistance(PrjCoordSys prjCoordSys, Unit
		// desUnit, Double distance)
		// {
		// Double resultDistance = distance;
		// try
		// {
		// Unit unit = Unit.Meter;
		// if (prjCoordSys.getType() == PrjCoordSysType.NoneEarth)
		// {
		// unit = prjCoordSys.CoordUnit;
		// }
		//
		// resultDistance = ConvertDistance(unit, desUnit, distance);
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return resultDistance;
		// }
		//
		// /// <summary>
		// /// 以指定单位作为参照，进行面积单位换算
		// /// </summary>
		// public static Double ConvertArea(Unit srcUnit, Unit desUnit, Double
		// area)
		// {
		// Double resultArea = area;
		// try
		// {
		// if (srcUnit != desUnit) // 两种单位不相同时才进行转换
		// {
		// resultArea = area * Math.Pow((Double)srcUnit / (Double)desUnit, 2);
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return resultArea;
		// }
		//
		// /// <summary>
		// /// 以投影系统的坐标单位作为参照，进行面积单位换算，平面坐标系使用坐标单位，其他坐标系单位默认为米
		// /// </summary>
		// public static Double ConvertArea(PrjCoordSys prjCoordSys, Unit
		// desUnit, Double area)
		// {
		// Double resultArea = area;
		// try
		// {
		// Unit unit = Unit.Meter;
		// if (prjCoordSys.getType() == PrjCoordSysType.NoneEarth)
		// {
		// unit = prjCoordSys.CoordUnit;
		// }
		// resultArea = ConvertArea(unit, desUnit, area);
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return resultArea;
		// }
		//
		// /// <summary>
		// /// 将度转换为度分秒
		// /// </summary>
		// /// <param name="douleValue"></param>
		// /// <returns></returns>
		// public static String ConvertDegreeToDMS(Double douleValue)
		// {
		// String result = "{0}°{1}′{2}″";
		// try
		// {
		// int degree = 1;
		// int minute = 0;
		// int second = 0;
		// degree = (int)douleValue;
		// Double doubleMS = (douleValue - degree)* 60;
		// minute = (int)doubleMS;
		// Double doubleSecond = (doubleMS - minute) * 60;
		// second = (int)doubleSecond;
		// if (minute == 0 && second == 0)
		// {
		// result = String.format("{0}°",degree);
		// }
		// result = String.format(result, degree, minute, second);
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return result;
		// }
		//
		// /// <summary>
		// /// 获取Unit枚举的所有成员
		// /// </summary>
		// public static Unit[] getUnitTypeList()
		// {
		// List<Unit> unitTypeList = new List<Unit>();
		// unitTypeList.Clear();
		// try
		// {
		// unitTypeList.Add(Unit.Kilometer);
		// unitTypeList.Add(Unit.Meter);
		// unitTypeList.Add(Unit.Decimeter);
		// unitTypeList.Add(Unit.Centimeter);
		// unitTypeList.Add(Unit.Millimeter);
		// unitTypeList.Add(Unit.Mile);
		// unitTypeList.Add(Unit.Yard);
		// unitTypeList.Add(Unit.Foot);
		// unitTypeList.Add(Unit.Inch);
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return unitTypeList.ToArray();
		// }
		// #endregion
		//
		// #region Function_Event
		//
		// #endregion
		//
		// #region Function_Private
		// /// <summary>
		// /// 初始化数学单位封装类
		// /// </summary>
		// private static void Initialize()
		// {
		// //CommonToolkit toolkit = new CommonToolkit();
		//
		// distanceUnitNames = new Dictionary<Unit, String>();
		// areaUnitNames = new Dictionary<AreaUnit, String>();
		// volumnUnitNames = new Dictionary<Unit, String>();
		// degreeformatNames = new Dictionary<Degreeformat, String>();
		//
		// // 距离单位
		// distanceUnitNames.Add(Unit.Millimeter,
		// CommonResources.String_DistanceUnit_Millimeter);
		// distanceUnitNames.Add(Unit.Centimeter,
		// CommonResources.String_DistanceUnit_Centimeter);
		// distanceUnitNames.Add(Unit.Decimeter,
		// CommonResources.String_DistanceUnit_Decimeter);
		// distanceUnitNames.Add(Unit.Meter,
		// CommonResources.String_DistanceUnit_Meter);
		// distanceUnitNames.Add(Unit.Kilometer,
		// CommonResources.String_DistanceUnit_Kilometer);
		// distanceUnitNames.Add(Unit.Inch,
		// CommonResources.String_DistanceUnit_Inch);
		// distanceUnitNames.Add(Unit.Foot,
		// CommonResources.String_DistanceUnit_Foot);
		// distanceUnitNames.Add(Unit.Mile,
		// CommonResources.String_DistanceUnit_Mile);
		// distanceUnitNames.Add(Unit.Degree,
		// CoreResources.String_Degree_format_Degree);
		// distanceUnitNames.Add(Unit.Yard,
		// CommonResources.String_DistanceUnit_Yard);
		//
		// // 面积单位(最新需求，面积单位建议增加亩，所以不能在用底层提供的Unit了，只能自定义AreaUnit)
		// areaUnitNames.Add(AreaUnit.Millimeter,
		// CommonResources.String_AreaUnit_Millimeter);
		// areaUnitNames.Add(AreaUnit.Centimeter,
		// CommonResources.String_AreaUnit_Centimeter);
		// areaUnitNames.Add(AreaUnit.Decimeter,
		// CommonResources.String_AreaUnit_Decimeter);
		// areaUnitNames.Add(AreaUnit.Meter,
		// CommonResources.String_AreaUnit_Meter);
		// areaUnitNames.Add(AreaUnit.Kilometer,
		// CommonResources.String_AreaUnit_Kilometer);
		// areaUnitNames.Add(AreaUnit.Inch,
		// CommonResources.String_AreaUnit_Inch);
		// areaUnitNames.Add(AreaUnit.Foot,
		// CommonResources.String_AreaUnit_Foot);
		// areaUnitNames.Add(AreaUnit.Mile,
		// CommonResources.String_AreaUnit_Mile);
		// areaUnitNames.Add(AreaUnit.Yard,
		// CommonResources.String_AreaUnit_Yard);
		// areaUnitNames.Add(AreaUnit.Acre,CommonResources.String_AreaUnit_Acre);
		//
		// //体积单位
		// volumnUnitNames.Add(Unit.Millimeter,
		// CoreResources.String_VolumnUnit_Millimeter);
		// volumnUnitNames.Add(Unit.Centimeter,
		// CoreResources.String_VolumnUnit_Centimeter);
		// volumnUnitNames.Add(Unit.Decimeter,
		// CoreResources.String_VolumnUnit_Decimeter);
		// volumnUnitNames.Add(Unit.Meter,
		// CoreResources.String_VolumnUnit_Meter);
		// volumnUnitNames.Add(Unit.Kilometer,
		// CoreResources.String_VolumnUnit_Kilometer);
		// volumnUnitNames.Add(Unit.Inch,
		// CoreResources.String_VolumnUnit_Inch);
		// volumnUnitNames.Add(Unit.Foot,
		// CoreResources.String_VolumnUnit_Foot);
		// volumnUnitNames.Add(Unit.Mile,
		// CoreResources.String_VolumnUnit_Mile);
		// volumnUnitNames.Add(Unit.Yard,
		// CoreResources.String_VolumnUnit_Yard);
		//
		// // 角度格式
		// degreeformatNames.Add(Degreeformat.Degree,
		// CoreResources.String_Degree_format_Degree);
		// degreeformatNames.Add(Degreeformat.DDMMSS,
		// CoreResources.String_Degree_format_DDMMSS);
		// degreeformatNames.Add(Degreeformat.Radian,
		// CoreResources.String_Degree_format_Radian);
		// }
		// #endregion
		//
		// #region Event
		//
		// #endregion
		//
		// #region InterfaceMembers
		//
		// #endregion
		//
		// #region NestedTypes
		//
		// #endregion
	}

	public static class WorkEnvironmentWrap {

		// /// <summary>
		// /// 发送工作环境
		// /// </summary>
		// public static void SendLoadWorkEnvironmentEvent(String
		// workEnvironment)
		// {
		// try
		// {
		// if (LoadWorkEnvironmentEvent != null)
		// {
		// LoadWorkEnvironmentEventArgs arg = new
		// LoadWorkEnvironmentEventArgs(workEnvironment);
		// LoadWorkEnvironmentEvent(null, arg);
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// }
		// }
		//
		// public static event LoadWorkEnvironmentEventHandler
		// LoadWorkEnvironmentEvent;
		// public delegate void LoadWorkEnvironmentEventHandler(Object sender,
		// LoadWorkEnvironmentEventArgs e);
		// public class LoadWorkEnvironmentEventArgs : EventArgs
		// {
		// public LoadWorkEnvironmentEventArgs(String workEnvironment)
		// {
		// workEnvironment = workEnvironment;
		// }
		//
		// private String workEnvironment;
		// public String workEnvironment
		// {
		// get
		// {
		// return workEnvironment;
		// }
		// }
		// }
	}

	public static class WorkspaceTypeWrap {

		// #region Variable
		//
		// #endregion
		//
		// #region Property
		//
		// #endregion
		//
		// #region Construct
		//
		// #endregion
		//
		// #region Function_Public
		// /// <summary>
		// /// 根据工作空间类型获取对应的资源字符串
		// /// </summary>
		// public static String getWorkspaceTypeName(WorkspaceType
		// workspaceType)
		// {
		// String workspaceTypeInfo = String.Empty;
		// try
		// {
		// if (workspaceType == WorkspaceType.Default)
		// {
		// workspaceTypeInfo = CoreResources.String_WorkspaceType_Default;
		// }
		// else if (workspaceType == WorkspaceType.Oracle)
		// {
		// workspaceTypeInfo = CoreResources.String_WorkspaceType_Oracle;
		// }
		// else if (workspaceType == WorkspaceType.SQL)
		// {
		// workspaceTypeInfo = CoreResources.String_WorkspaceType_SQL;
		// }
		// else if (workspaceType == WorkspaceType.SMW)
		// {
		// workspaceTypeInfo = CoreResources.String_WorkspaceType_SMW;
		// }
		// else if (workspaceType == WorkspaceType.SXW)
		// {
		// workspaceTypeInfo = CoreResources.String_WorkspaceType_SXW;
		// }
		// else if (workspaceType == WorkspaceType.SMWU)
		// {
		// workspaceTypeInfo = CoreResources.String_WorkspaceType_SMWU;
		// }
		// else if (workspaceType == WorkspaceType.SXWU)
		// {
		// workspaceTypeInfo = CoreResources.String_WorkspaceType_SXWU;
		// }
		// } catch (Exception ex) {
		// Application.getActiveApplication().getOutput().output(ex);
		// }
		// return workspaceTypeInfo;
		// }
		//
		// /// <summary>
		// /// 根据文件的扩展名获取对应的工作空间类型
		// /// </summary>
		// public static WorkspaceType getWorkspaceTypeByFileExt(String fileExt)
		// {
		// WorkspaceType workspaceType = WorkspaceType.Default;
		// fileExt = fileExt.toLowerCase();
		//
		// if (fileExt.Equals(".sxw"))
		// {
		// workspaceType = WorkspaceType.SXW;
		// }
		// else if (fileExt.Equals(".smw"))
		// {
		// workspaceType = WorkspaceType.SMW;
		// }
		// else if (fileExt.Equals(".smwu"))
		// {
		// workspaceType = WorkspaceType.SMWU;
		// }
		// else if (fileExt.Equals(".sxwu"))
		// {
		// workspaceType = WorkspaceType.SXWU;
		// }
		// else
		// {
		// workspaceType = WorkspaceType.Default;
		// }
		//
		// return workspaceType;
		// }
		// #endregion
		//
		// #region Function_Event
		//
		// #endregion
		//
		// #region Function_Private
		//
		// #endregion
		//
		// #region Event
		//
		// #endregion
		//
		// #region InterfaceMembers
		//
		// #endregion
		//
		// #region NestedTypes
		//
		// #endregion
	}

	public static class WorkspaceWrap {

		private static transient CopyOnWriteArrayList<SaveWorkspaceListener> saveWorkspaceListeners = new CopyOnWriteArrayList<SaveWorkspaceListener>();
		public static PluginInfo pluginInfo = null;
		public static SmMenu recentWorkspaceMenu = null;

		public static synchronized void addSaveWorkspaceListener(SaveWorkspaceListener listener) {
			if (saveWorkspaceListeners == null) {
				saveWorkspaceListeners = new CopyOnWriteArrayList<SaveWorkspaceListener>();
			}

			if (!saveWorkspaceListeners.contains(listener)) {
				saveWorkspaceListeners.add(listener);
			}
		}

		public static void removeSaveWorkspaceListener(SaveWorkspaceListener listener) {
			if (saveWorkspaceListeners != null && saveWorkspaceListeners.contains(listener)) {
				saveWorkspaceListeners.remove(listener);
			}
		}

		public static boolean fireSaveWorkspaceEvent(boolean isSaveCurrentWorkspace, boolean isCloseAllOpenedWindows, boolean isCloseWorkspace,
				WorkspaceConnectionInfo info) {
			boolean result = true;
			try {
				SaveWorkspaceEvent event = new SaveWorkspaceEvent(Application.getActiveApplication().getMainFrame(), isSaveCurrentWorkspace,
						isCloseAllOpenedWindows, isCloseWorkspace, info);
				fireSaveWorkspaceEvent(event);
				result = event.getHandled();
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return result;
		}

		private static void fireSaveWorkspaceEvent(SaveWorkspaceEvent event) {
			if (saveWorkspaceListeners != null) {
				Iterator<SaveWorkspaceListener> iter = saveWorkspaceListeners.iterator();
				while (iter.hasNext()) {
					SaveWorkspaceListener listener = iter.next();
					listener.saveWorkspace(event);
				}
			}
		}

		/**
		 * 打开所有类型的工作空间，建议其他地方在调用的时候直接构造WorkspaceConnectionInfo 调用该方法。
		 * 
		 * @param info 工作空间连接信息
		 * @param first 是否是第一次打开
		 * @return 打开工作空间的结果
		 */
		public static OpenWorkspaceResult openWorkspace(WorkspaceConnectionInfo info, boolean first) {
			OpenWorkspaceResult result = OpenWorkspaceResult.FAILED_PASSWORD_WRONG;
			try {
				// 打开新的工作空间之前需要先关闭当前工作空间
				if (CommonToolkit.WorkspaceWrap.closeWorkspace()) {
					Component parent = (Component) Application.getActiveApplication().getMainFrame();
					((JFrame) Application.getActiveApplication().getMainFrame()).setCursor(Cursor.WAIT_CURSOR);
					Toolkit.clearErrors();
					boolean isOpened = false;
					HashMap<String, String> readOnlyDatasourceDictionary = new HashMap<String, String>();
					try {
						// 如果数据源中含有只读文件，则给出提示是否已只读打开。
						// 先构造一个工作空间，判断一下是否需要进行提示（这个主要是处理UI问题，因为数据源只有在打开工作空间的情况下才能够判断
						// 如果直接在application下的工作空间下判断，界面上就会出现 打开失败-
						// 提示是否只读打开-重新打开的现象，体验不好）
						Workspace workspace = new Workspace();
						isOpened = workspace.open(info);

						if (isOpened
								&& (workspace.getType() == WorkspaceType.SMW || workspace.getType() == WorkspaceType.SMWU
										|| workspace.getType() == WorkspaceType.SXW || workspace.getType() == WorkspaceType.SXWU)) {
							// FormOpenReadOnlyDatasourceMessageBox messageBox =
							// null;
							boolean isAllExcuteThisOperation = false;
							for (int i = 0; i < workspace.getDatasources().getCount(); i++) {
								Datasource datasource = workspace.getDatasources().get(i);
								// 如果上一次是以只读打开形式打开的文件，则保存工作空间后可以成功打开，故不需要给出提示。
								// 所以如果数据源没有成功打开，且文件类型是只读类型，则给出提示。
								if (!datasource.isOpened()) {
									String datasourceFilePath = datasource.getConnectionInfo().getServer();
									if (!datasourceFilePath.contains(":memory:")) {
										File file = new File(datasourceFilePath);
										// 仅限于文件型工作空间与文件型数据源，sdb已淘汰，不进行判断
										if (file.getName().toLowerCase().endsWith(".udb")) {
											String datasourceUddPath = datasourceFilePath.substring(0, datasourceFilePath.lastIndexOf(".")) + ".udd";// datasource.getConnectionInfo().getServer().toLowerCase().replace("udb",
																																						// "udd");
											File uddFile = new File(datasourceUddPath);
											if (file.exists() && uddFile.exists()) {
												if (!file.canWrite() || !uddFile.canWrite()) {
													String message = MessageFormat.format(CoreProperties.getString("String_OpenReadOnlyDatasourceWarning"),
															datasourceFilePath);
													if (!isAllExcuteThisOperation) {
														int dialogResult = JOptionPane.showConfirmDialog(parent, message);
														if (dialogResult == JOptionPane.YES_OPTION) {
															readOnlyDatasourceDictionary.put(datasourceFilePath, datasource.getAlias());
															// if
															// (messageBox.AllDatasourcesExcuteThisOperation)
															// {
															isAllExcuteThisOperation = true;
															// }
														}
													} else if (isAllExcuteThisOperation) {
														readOnlyDatasourceDictionary.put(datasourceFilePath, datasource.getAlias());
													}
												}
											}
										}
									}
								}
							}
						}
						workspace.close();
						workspace.dispose();

						// 真正的打开Application下面的工作空间
						isOpened = Application.getActiveApplication().getWorkspace().open(info);
						if (isOpened) {
							result = OpenWorkspaceResult.SUCCESSED;
							for (Entry<String, String> entry : readOnlyDatasourceDictionary.entrySet()) {
								Application.getActiveApplication().getWorkspace().getDatasources().close(entry.getValue());
								CommonToolkit.DatasourceWrap.openFileDatasource(entry.getKey(), "", true, true);
							}
							/*
							 * <<<<<<< HEAD Iterator iterator =
							 * readOnlyDatasourceDictionary.keySet().iterator();
							 * while (iterator.hasNext()) { Object a =
							 * iterator.next(); String entry = (String)
							 * iterator.next();
							 * Application.getActiveApplication(
							 * ).getWorkspace().getDatasources().close(entry);
							 * readOnlyDatasourceDictionary
							 * .get(iterator.next()); Datasource datasource =
							 * CommonToolkit
							 * .DatasourceWrap.openFileDatasource(entry, "",
							 * true, true); } ======= Iterator iterator =
							 * readOnlyDatasourceDictionary.keySet().iterator();
							 * while (iterator.hasNext()) { Object a =
							 * iterator.next(); String entry = (String)
							 * iterator.next();
							 * Application.getActiveApplication(
							 * ).getWorkspace().getDatasources().close(entry);
							 * readOnlyDatasourceDictionary
							 * .get(iterator.next()); Datasource datasource =
							 * CommonToolkit
							 * .DatasourceWrap.openFileDatasource(entry, "",
							 * true, true); } >>>>>>>
							 * 533c07acf1421d7eb36d9a2c1cae01b53ec85ebe
							 */

							for (int index = Application.getActiveApplication().getWorkspace().getDatasources().getCount() - 1; index >= 0; index--) {
								Datasource datasource = Application.getActiveApplication().getWorkspace().getDatasources().get(index);
								if (!datasource.isOpened()) {
									if (!datasource.getConnectionInfo().getServer().contains(":memory:")) {
										String failedInfo = String.format(CommonProperties.getString("String_Message_DataSource_Openfail"),
												datasource.getAlias());
										Application.getActiveApplication().getOutput().output(failedInfo);
									} else {
										Application.getActiveApplication().getWorkspace().getDatasources().close(datasource.getAlias());
									}
								}
							}
						} else {
							ErrorInfo[] errorInfos = Toolkit.getLastErrors(2);
							for (int i = 0; i < errorInfos.length; i++) {
								if (errorInfos[i].getMarker().equals(CoreProperties.getString("String_UGS_PASSWORD"))) {
									if (!first) {
										// Application.getActiveApplication().getOutput().output(errorInfos[i].getMessage());
									}
									result = OpenWorkspaceResult.FAILED_PASSWORD_WRONG;
									break;
								} else {
									// Application.getActiveApplication().getOutput().output(errorInfos[i].getMessage());
									result = OpenWorkspaceResult.FAILED_UNKNOW;
								}
							}
						}
					} catch (Exception ex) {
						if (ex.getMessage().equalsIgnoreCase("supermap_license_error_wronglicensedata")) {
							Application.getActiveApplication().getOutput().output(CoreProperties.getString("String_Wronglicensedata"));
						} else if (ex.getMessage().equalsIgnoreCase(CoreProperties.getString("String_UGS_PASSWORD_Message"))) {
							result = OpenWorkspaceResult.FAILED_PASSWORD_WRONG;
						} else {
							ErrorInfo[] errorInfos = Toolkit.getLastErrors(2);
							for (int i = 0; i < errorInfos.length; i++) {
								if (errorInfos[i].getMarker().equals(CoreProperties.getString("String_UGS_PASSWORD"))) {
									if (!first) {
										Application.getActiveApplication().getOutput().output(errorInfos[i].getMessage());
									}
									result = OpenWorkspaceResult.FAILED_PASSWORD_WRONG;
									break;
								} else {
									Application.getActiveApplication().getOutput().output(errorInfos[i].getMessage());
									result = OpenWorkspaceResult.FAILED_UNKNOW;
								}
							}
						}
						if (result != OpenWorkspaceResult.FAILED_PASSWORD_WRONG) {
							Application.getActiveApplication().getOutput().output(ex);
						}
					}

					if (info.getType() == WorkspaceType.SMW || info.getType() == WorkspaceType.SMWU || info.getType() == WorkspaceType.SXWU
							|| info.getType() == WorkspaceType.SXW) {
						// 如果是文件型工作空间并且打开成功了，则需要添加到最近文件列表中
						if (result == OpenWorkspaceResult.SUCCESSED) {
							addWorkspaceFileToRecentFile(info.getServer());
						}
					}
				} else {
					result = OpenWorkspaceResult.FAILED_CANCEL;
				}
			} catch (Exception ex) {
				// Application.getActiveApplication().getOutput().output(ex);
			} finally {
				((JFrame) Application.getActiveApplication().getMainFrame()).setCursor(Cursor.DEFAULT_CURSOR);
			}

			return result;
		}

		/**
		 * 将指定路径的工作空间添加到最近文件列表
		 * 
		 * @param filePath 要加入列表的文件路径
		 * @return 添加成功返回true，失败返回false
		 */
		public static void addWorkspaceFileToRecentFile(String filePath) {
			try {
				filePath = filePath.replace("\\", "/");
				if (recentWorkspaceMenu != null) {
					removeRecentFile(filePath);

					XMLCommand xmlCommand = new XMLCommand(pluginInfo);
					xmlCommand.setCtrlActionClass("CtrlActionRecentFiles");
					xmlCommand.setLabel(filePath);
					xmlCommand.setTooltip(filePath);
					SmMenuItem menuItem = new SmMenuItem(null, xmlCommand, recentWorkspaceMenu);
					if (menuItem != null) {
						recentWorkspaceMenu.insert((IBaseItem) menuItem, 0);
						if (recentWorkspaceMenu.getItemCount() > 7) {
							removeRecentFile(((SmMenuItem) recentWorkspaceMenu.getItem(7)).getText());
						}
						saveRecentFile(filePath);
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
		}

		public static void initRecentFileMenu() {
			try {
				String recentFilePath = PathUtilties.getFullPathName(_XMLTag.g_RecentFileXML, false);
				File file = new File(recentFilePath);
				if (file.exists()) {
					Element element = XmlUtilties.getRootNode(recentFilePath);
					if (element != null) {
						NodeList nodes = element.getChildNodes();
						for (int i = 0; i < nodes.getLength(); i++) {
							if (nodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
								Element item = (Element) (nodes.item(i));
								if (item.getNodeName().equalsIgnoreCase(_XMLTag.g_NodeGroup)) {
									String type = item.getAttribute(_XMLTag.g_ControlLabel);
									if (type.equalsIgnoreCase(CoreProperties.getString("String_RecentWorkspace"))) {
										NodeList childnNodes = item.getChildNodes();
										for (int j = 0; j < childnNodes.getLength(); j++) {
											if (childnNodes.item(j).getNodeType() == Node.ELEMENT_NODE) {
												Element childItem = (Element) (childnNodes.item(j));
												String filePath = childItem.getAttribute(_XMLTag.g_NodeContent);
												XMLCommand xmlCommand = new XMLCommand(pluginInfo);
												xmlCommand.setCtrlActionClass("CtrlActionRecentFiles");
												xmlCommand.setLabel(filePath);
												xmlCommand.setTooltip(filePath);
												SmMenuItem menuItem = new SmMenuItem(null, xmlCommand, recentWorkspaceMenu);
												if (menuItem != null) {
													recentWorkspaceMenu.add((IBaseItem) menuItem);
												}
											}
										}
									}
								}
							}
						}
					}
				}

			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
		}

		public static void saveRecentFile(String filePath) {
			try {
				String recentFilePath = PathUtilties.getFullPathName(_XMLTag.g_RecentFileXML, false);
				File file = new File(recentFilePath);
				if (file.exists()) {
					Document document = XmlUtilties.getDocument(recentFilePath);
					Element element = document.getDocumentElement();
					if (element != null) {
						NodeList nodes = element.getChildNodes();
						for (int i = 0; i < nodes.getLength(); i++) {
							if (nodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
								Element item = (Element) (nodes.item(i));
								if (item.getNodeName().equalsIgnoreCase(_XMLTag.g_NodeGroup)) {
									String type = item.getAttribute(_XMLTag.g_ControlLabel);
									if (type.equalsIgnoreCase(CoreProperties.getString("String_RecentWorkspace"))) {
										// 把原来的记录全部取出来保存
										NodeList childnNodes = item.getChildNodes();
										ArrayList<String> recentFiles = new ArrayList<String>();
										for (int j = childnNodes.getLength() - 1; j >= 0; j--) {
											if (childnNodes.item(j).getNodeType() == Node.ELEMENT_NODE) {
												Element childItem = (Element) (childnNodes.item(j));
												recentFiles.add(0, childItem.getAttribute(_XMLTag.g_NodeContent));
											}
											item.removeChild(childnNodes.item(j));
										}

										// 添加新纪录
										Element newItem = document.createElement("item");
										newItem.setAttribute(_XMLTag.g_NodeContent, filePath);
										item.appendChild(newItem);

										// 把之前的记录再写入
										for (int j = 0; j < recentFiles.size(); j++) {
											newItem = document.createElement("item");
											newItem.setAttribute(_XMLTag.g_NodeContent, recentFiles.get(j));
											item.appendChild(newItem);
										}

										// 保存文件
										try {
											XmlUtilties.saveXml(recentFilePath, (Node) document, document.getXmlEncoding());
										} catch (Exception e) {
											Application.getActiveApplication().getOutput().output(e);
										}

										break;
									}
								}
							}
						}
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
		}

		public static void removeRecentFile(String filePath) {
			try {
				for (IBaseItem item : recentWorkspaceMenu.items()) {
					if (((SmMenuItem) item).getToolTipText().equals(filePath)) {
						recentWorkspaceMenu.remove((IBaseItem) item);
						break;
					}
				}

				String recentFilePath = PathUtilties.getFullPathName(_XMLTag.g_RecentFileXML, false);
				File file = new File(recentFilePath);
				if (file.exists()) {
					Document document = XmlUtilties.getDocument(recentFilePath);
					Element element = document.getDocumentElement();
					if (element != null) {
						NodeList nodes = element.getChildNodes();
						for (int i = 0; i < nodes.getLength(); i++) {
							if (nodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
								Element item = (Element) (nodes.item(i));
								if (item.getNodeName().equalsIgnoreCase(_XMLTag.g_NodeGroup)) {
									String type = item.getAttribute(_XMLTag.g_ControlLabel);
									if (type.equalsIgnoreCase(CoreProperties.getString("String_RecentWorkspace"))) {
										NodeList childnNodes = item.getChildNodes();
										for (int j = 0; j < childnNodes.getLength(); j++) {
											if (childnNodes.item(j).getNodeType() == Node.ELEMENT_NODE) {
												Element childItem = (Element) (childnNodes.item(j));
												String itemPath = childItem.getAttribute(_XMLTag.g_NodeContent);
												if (itemPath.equalsIgnoreCase(filePath)) {
													item.removeChild(childnNodes.item(j));
												}
											}
										}

										// 保存文件
										try {
											XmlUtilties.saveXml(recentFilePath, (Node) document, document.getXmlEncoding());
										} catch (Exception e) {
											Application.getActiveApplication().getOutput().output(e);
										}

										break;
									}
								}
							}
						}
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
		}

		/**
		 * 判断当前工作空间文件是否只读
		 * 
		 * @return
		 */
		public static boolean isWorkspaceReadonly() {
			String path = Application.getActiveApplication().getWorkspace().getConnectionInfo().getServer();
			boolean isReadOnly = false;

			File file = new File(path);
			if (file.exists()) {
				isReadOnly = !file.canWrite();
			}

			if (isReadOnly) {
				JOptionPane.showConfirmDialog(null, CoreProperties.getString("String_workspaceReadonly"),
						CoreProperties.getString("String_workspaceReadonlyTitle"), JOptionPane.OK_OPTION, JOptionPane.WARNING_MESSAGE);
			}

			return isReadOnly;
		}

		/**
		 * 判断工作空间是否被修改过
		 * 
		 * @return
		 */
		public static boolean isWorkspaceModified() {
			boolean result = false;
			try {
				result = true;
				result = Application.getActiveApplication().getWorkspace().isModified();
				if (!result) {
					for (int index = 0; index < Application.getActiveApplication().getMainFrame().getFormManager().getCount(); index++) {
						IForm form = Application.getActiveApplication().getMainFrame().getFormManager().get(index);
						if (form == null) {
							continue;
						} else if (form instanceof IFormMap && ((IFormMap) form).getMapControl() != null && ((IFormMap) form).getMapControl().getMap() != null
								&& ((IFormMap) form).getMapControl().getMap().isModified()) {
							result = true;
							break;
						} else if (form instanceof IFormLayout && ((IFormLayout) form).getMapLayoutControl() != null
								&& ((IFormLayout) form).getMapLayoutControl().getMapLayout() != null
								&& ((IFormLayout) form).getMapLayoutControl().getMapLayout().isModified()) {
							result = true;
							break;
						} else if (form instanceof IFormScene) {
							result = true;
							break;
						}
					}
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return result;
		}

		/**
		 * 关闭工作空间
		 */
		public static boolean closeWorkspace() {
			boolean isClose = true;
			int result = -1;
			try {
				boolean needSave = false;
				boolean isContinue = true;
				Component parent = (Component) Application.getActiveApplication().getMainFrame();
				// 提示保存内存型数据源
				if (CommonToolkit.DatasourceWrap.isContianMemoryDatasource(Application.getActiveApplication().getWorkspace())) {
					String[] datasources = CommonToolkit.DatasourceWrap.getMemoryDatasources(Application.getActiveApplication().getWorkspace());
					String datasourcesName = "";
					for (int i = 0; i < datasources.length - 1; i++) {
						datasourcesName += datasources[i] + "、";
					}
					datasourcesName += datasources[datasources.length - 1];//
					String message = MessageFormat.format(CommonProperties.getString("String_Message_CloseMemoryDatasource"), datasourcesName);
					result = JOptionPane.showConfirmDialog(parent, message, CommonProperties.getString("String_Title_CloseWorkspace"),
							JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
					if (result == JOptionPane.NO_OPTION) {
						isContinue = false;
					} else {
						CommonToolkit.DatasourceWrap.CloseMemoryDatasource();
					}
				}

				if (isContinue) {
					if (CommonToolkit.WorkspaceWrap.isWorkspaceModified()) {
						if (GlobalParameters.isShowFormClosingInfo()) {
							result = JOptionPane.showConfirmDialog(parent, CoreProperties.getString("String_SaveWorkspacePrompt"),
									CoreProperties.getString("String_SaveWorkspace"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
							if (result == JOptionPane.NO_OPTION) {
								if (Application.getActiveApplication().getMainFrame().getFormManager().closeAll(false)) {
									Application.getActiveApplication().getWorkspace().close();
								}
							} else if (result == JOptionPane.YES_OPTION) {
								needSave = true;
							} else if (result == JOptionPane.CANCEL_OPTION) {
								isClose = false;
							}
						} else {
							needSave = true;
						}

						if (needSave) {
							if (Application.getActiveApplication().getMainFrame().getFormManager().closeAll(true)) {
								if (isWorkspaceReadonly()) {
									isClose = fireSaveWorkspaceEvent(true, true, true, null);
								} else {
									if (Application.getActiveApplication().getWorkspace().getType() == WorkspaceType.DEFAULT) {
										isClose = fireSaveWorkspaceEvent(true, true, true, null);// 对于默认工作空间来说，这时候需要另存
									} else {
										if (!Application.getActiveApplication().getWorkspace().save()) {
											isClose = fireSaveWorkspaceEvent(true, true, true, null);
										}
									}
								}

								if (isClose) {
									Application.getActiveApplication().getWorkspace().close();
								}
							} else {
								isClose = false;
							}
						}
					} else {
						if (Application.getActiveApplication().getMainFrame().getFormManager().closeAll(true)) {
							Application.getActiveApplication().getWorkspace().close();
						} else {
							isClose = false;
						}
					}
				} else {
					isClose = false;
				}
			} catch (Exception ex) {
				Application.getActiveApplication().getOutput().output(ex);
			}
			return isClose;
		}
	}

	/**
	 * 数据集图标路径对应工具类
	 * 
	 * @author xie
	 *
	 */
	public static class DatasetImageWrap {
		private static HashMap<DatasetType, String> datasetImage = null;

		private static void initialize() {
			if (null != datasetImage) {
				return;
			}
			datasetImage = new HashMap<DatasetType, String>();
			String fileParentPath = "/com/supermap/desktop/controlsresources/WorkspaceManager/Dataset/";
			datasetImage.put(DatasetType.CAD, fileParentPath + "Image_DatasetCAD_Normal.png");
			datasetImage.put(DatasetType.GRID, fileParentPath + "Image_DatasetGrid_Normal.png");
			datasetImage.put(DatasetType.GRIDCOLLECTION, fileParentPath + "Image_DatasetGridCollection_Normal.png");
			datasetImage.put(DatasetType.IMAGE, fileParentPath + "Image_DatasetImage_Normal.png");
			datasetImage.put(DatasetType.IMAGECOLLECTION, fileParentPath + "Image_DatasetImageCollection_Normal.png");
			datasetImage.put(DatasetType.LINE, fileParentPath + "Image_DatasetLine_Normal.png");
			datasetImage.put(DatasetType.LINE3D, fileParentPath + "Image_DatasetLine3D_Normal.png");
			datasetImage.put(DatasetType.LINEM, fileParentPath + "Image_DatasetLineM_Normal.png");
			datasetImage.put(DatasetType.LINKTABLE, fileParentPath + "Image_DatasetLineTable_Normal.png");
			datasetImage.put(DatasetType.MODEL, fileParentPath + "Image_DatasetModel_Normal.png");
			datasetImage.put(DatasetType.NETWORK, fileParentPath + "Image_DatasetNetwork_Normal.png");
			datasetImage.put(DatasetType.NETWORK3D, fileParentPath + "Image_DatasetNetwork3D_Normal.png");
			datasetImage.put(DatasetType.PARAMETRICLINE, fileParentPath + "Image_DatasetParametricLine_Normal.png");
			datasetImage.put(DatasetType.PARAMETRICREGION, fileParentPath + "Image_DatasetParametricRegion_Normal.png");
			datasetImage.put(DatasetType.POINT, fileParentPath + "Image_DatasetPoint_Normal.png");
			datasetImage.put(DatasetType.POINT3D, fileParentPath + "Image_DatasetPoint3D_Normal.png");
			datasetImage.put(DatasetType.REGION, fileParentPath + "Image_DatasetRegion_Normal.png");
			datasetImage.put(DatasetType.REGION3D, fileParentPath + "Image_DatasetRegion3D_Normal.png");
			datasetImage.put(DatasetType.TABULAR, fileParentPath + "Image_DatasetTabular_Normal.png");
			datasetImage.put(DatasetType.TEXT, fileParentPath + "Image_DatasetText_Normal.png");
			datasetImage.put(DatasetType.TOPOLOGY, fileParentPath + "Image_DatasetTopology_Normal.png");
			datasetImage.put(DatasetType.WCS, fileParentPath + "Image_DatasetWCS_Normal.png");
			datasetImage.put(DatasetType.WMS, fileParentPath + "Image_DatasetWMS_Normal.png");
			datasetImage.put(DatasetType.TEXTURE, fileParentPath + "Image_DataseSimpleDataset_Normal.png");
			String filePathTopo = fileParentPath + "TopologyDatasetRelations/Image_TopologyDatasetRelations_Normal.png";
			datasetImage.put(DatasetType.TOPOLOGY, filePathTopo);
		}

		/**
		 * 根据数据集类型返回对应的图标所在的相对路径
		 * 
		 * @param type
		 * @return
		 */
		public static String getImageIconPath(DatasetType type) {
			String resultIcon = "";
			try {
				initialize();
				if (null == type) {
					return "";
				} else {
					Iterator<?> iterator = datasetImage.entrySet().iterator();
					while (iterator.hasNext()) {
						java.util.Map.Entry<?, ?> entry = (java.util.Map.Entry<?, ?>) iterator.next();
						if (type == entry.getKey()) {
							resultIcon = (String) entry.getValue();
						}
					}
				}
			} catch (Exception e) {
				Application.getActiveApplication().getOutput().output(e);
			}
			return resultIcon;
		}

		/**
		 * 根据数据集中文名得到数据集图标所在的相对路径
		 * 
		 * @param datasetName
		 * @return
		 */
		public static String getImageIconPath(String datasetTypeName) {
			DatasetType type = DatasetTypeWrap.findType(datasetTypeName);
			return getImageIconPath(type);
		}
	}

	public static class DatasourceImageWrap {
		private static HashMap<EngineType, String> datasourceImage = null;

		private static void initialize() {
			if (null != datasourceImage) {
				return;
			}
			datasourceImage = new HashMap<EngineType, String>();
			String fileParentPath = "/com/supermap/desktop/controlsresources/WorkspaceManager/Datasource/";
			datasourceImage.put(EngineType.DB2, fileParentPath + "Image_DatasourceDB2_Normal.png");
			datasourceImage.put(EngineType.GOOGLEMAPS, fileParentPath + "Image_DatasourceGoogleMaps_Normal.png");
			datasourceImage.put(EngineType.IMAGEPLUGINS, fileParentPath + "Image_DatasourceImagePlugins_Normal.png");
			datasourceImage.put(EngineType.OGC, fileParentPath + "Image_DatasourceOGC_Normal.png");
			datasourceImage.put(EngineType.ORACLEPLUS, fileParentPath + "Image_DatasourceOraclePlus_Normal.png");
			datasourceImage.put(EngineType.ORACLESPATIAL, fileParentPath + "Image_DatasourceOracleSpatial_Normal.png");
			datasourceImage.put(EngineType.POSTGRESQL, fileParentPath + "Image_DatasourcePostgreSQL_Normal.png");
			datasourceImage.put(EngineType.SQLPLUS, fileParentPath + "Image_DatasourceSQLPlus_Normal.png");
			datasourceImage.put(EngineType.UDB, fileParentPath + "Image_DatasourceUDB_Normal.png");
			datasourceImage.put(null, fileParentPath+"Image_Datasources_Normal.png");
		}

		/**
		 * 根据数据源引擎类型返回对应的图标所在的相对路径
		 * 
		 * @param type
		 * @return
		 */
		public static String getImageIconPath(EngineType type) {
			String resultIcon = "";
			try {
				initialize();
				Iterator<?> iterator = datasourceImage.entrySet().iterator();
				while (iterator.hasNext()) {
					java.util.Map.Entry<?, ?> entry = (java.util.Map.Entry<?, ?>) iterator.next();
					if (type == entry.getKey()) {
						resultIcon = (String) entry.getValue();
					}
				}

			} catch (Exception e) {
				Application.getActiveApplication().getOutput().output(e);
			}
			return resultIcon;
		}
	}

	public static class LayerImageWrap {
		private static HashMap<DatasetType, String> layerImage = null;

		private static void initialize() {
			if (null != layerImage) {
				return;
			}
			layerImage = new HashMap<DatasetType, String>();
			String fileParentPath = "/com/supermap/desktop/coreresources/Layer/";
			layerImage.put(DatasetType.CAD, fileParentPath + "Image_Layer_CAD.png");
			layerImage.put(DatasetType.LINEM, fileParentPath + "Image_Layer_LineM.png");
			layerImage.put(DatasetType.NETWORK, fileParentPath + "Image_Layer_Net.png");
			layerImage.put(DatasetType.TEXT, fileParentPath + "Image_Layer_TextLayer.png");
		}

		/**
		 * 根据数据集类型返回对应的图标所在的相对路径
		 * 
		 * @param type
		 * @return
		 */
		public static String getImageIconPath(DatasetType type) {
			String resultIcon = "";
			try {
				initialize();
				if (null == type) {
					return "";
				} else {
					Iterator<?> iterator = layerImage.entrySet().iterator();
					while (iterator.hasNext()) {
						java.util.Map.Entry<?, ?> entry = (java.util.Map.Entry<?, ?>) iterator.next();
						if (type == entry.getKey()) {
							resultIcon = (String) entry.getValue();
						}
					}
				}
			} catch (Exception e) {
				Application.getActiveApplication().getOutput().output(e);
			}
			return resultIcon;
		}
	}
}
